diff --git a/Doc/Sd1/gettingStarted.xml b/Doc/Sd1/gettingStarted.xml index 5fdf7ce95d2766c1fef637ae9152652e854ecf86..623a3aa35cb6fda2ae517f6d325150992cd20c5b 100644 --- a/Doc/Sd1/gettingStarted.xml +++ b/Doc/Sd1/gettingStarted.xml @@ -2293,10 +2293,9 @@ nano ~/.m2/settings.xml <co linkends="sd1_fig_mavenMiRepo-2" <figure xml:id="sd1_fig_mavenMiRepoCliTest"> <title><xref linkend="glo_CLI"/> archetype test</title> - <screen>mvn --batch-mode -e archetype:generate \ --DgroupId=de.hdm_stuttgart.mi.sd1 \ --DartifactId=first -Dversion=0.9 -DarchetypeGroupId=de.hdm_stuttgart.mi \ --DarchetypeArtifactId=<emphasis role="red">mi-maven-archetype-quickstart</emphasis> -DarchetypeVersion=1.2 + <screen>mvn --batch-mode -e archetype:generate -DgroupId=de.hdm_stuttgart.mi.sd1 \ +-DartifactId=second -Dversion=0.9 -DarchetypeGroupId=de.hdm_stuttgart.mi \ +-DarchetypeArtifactId=<emphasis role="red">mi-maven-archetype-helloworld</emphasis> -DarchetypeVersion=1.2 [INFO] Scanning for projects... ... @@ -2346,7 +2345,7 @@ nano ~/.m2/settings.xml <co linkends="sd1_fig_mavenMiRepo-2" <property>archetypeVersion</property> uniquely identify an archetype worldwide.</para> - <para><package>mi-maven-archetype-quickstart</package> denotes one + <para><package>mi-maven-archetype-helloworld</package> denotes one of several <link xlink:href="https://maven.mi.hdm-stuttgart.de/nexus/#browse/browse:mi-maven">available archetypes</link>.</para> @@ -2371,14 +2370,9 @@ nano ~/.m2/settings.xml <co linkends="sd1_fig_mavenMiRepo-2" > find . -type f <emphasis role="red"># Search recursively for files</emphasis> ./.gitignore <co linkends="sd1_fig_mavenFirstPrjLayout-1" xml:id="sd1_fig_mavenFirstPrjLayout-1-co"/> -./src/test/java/de/hdm_stuttgart/mi/sd1/AppTest.java <co - linkends="sd1_fig_mavenFirstPrjLayout-2" - xml:id="sd1_fig_mavenFirstPrjLayout-2-co"/> ./src/main/java/de/hdm_stuttgart/mi/sd1/App.java <co linkends="sd1_fig_mavenFirstPrjLayout-3" xml:id="sd1_fig_mavenFirstPrjLayout-3-co"/> -./src/main/resources/log4j2.xml <co linkends="sd1_fig_mavenFirstPrjLayout-4" - xml:id="sd1_fig_mavenFirstPrjLayout-4-co"/> ./pom.xml <co linkends="sd1_fig_mavenFirstPrjLayout-5" xml:id="sd1_fig_mavenFirstPrjLayout-5-co"/></screen> @@ -2390,25 +2384,12 @@ nano ~/.m2/settings.xml <co linkends="sd1_fig_mavenMiRepo-2" control.</para> </callout> - <callout arearefs="sd1_fig_mavenFirstPrjLayout-2-co" - xml:id="sd1_fig_mavenFirstPrjLayout-2"> - <para><xref linkend="glo_Java"/> source file defining automated - <xref linkend="glo_Junit"/> tests.</para> - </callout> - <callout arearefs="sd1_fig_mavenFirstPrjLayout-3-co" xml:id="sd1_fig_mavenFirstPrjLayout-3"> <para><xref linkend="glo_Java"/> source file containing an executable <methodname>main()</methodname> class.</para> </callout> - <callout arearefs="sd1_fig_mavenFirstPrjLayout-4-co" - xml:id="sd1_fig_mavenFirstPrjLayout-4"> - <para>Configuring <link - xlink:href="https://logging.apache.org/log4j">Apache Log4j logging - framework</link>.</para> - </callout> - <callout arearefs="sd1_fig_mavenFirstPrjLayout-5-co" xml:id="sd1_fig_mavenFirstPrjLayout-5"> <para>The <emphasis role="red">P</emphasis>roject <emphasis @@ -2442,79 +2423,37 @@ nano ~/.m2/settings.xml <co linkends="sd1_fig_mavenMiRepo-2" ./target/classes/<emphasis role="red">de/hdm_stuttgart/mi/sd1/App.class</emphasis></screen> </figure> - <qandaset defaultlabel="qanda" xml:id="sd1_qanda_WhyDoesExecFail"> - <title>What about execution?</title> - - <qandadiv> - <qandaentry> - <question> - <para>Follow the previous steps creating your own - <package>mi-maven-archetype-quickstart</package> based project - and execute <command>mvn</command> <option>compile</option>. - Then try to execute the generated bytecode file:</para> - - <screen>cd target/classes -java de.hdm_stuttgart.mi.sd1.App</screen> - - <para>What happens? Explain this result.</para> - </question> - - <answer> - <para>Execution fails:</para> - - <screen>> java de.hdm_stuttgart.mi.sd1.App -Exception in thread "main" java.lang.NoClassDefFoundError: - org/apache/logging/log4j/LogManager - at de.hdm_stuttgart.mi.sd1.App.<clinit>(App.java:14) -Caused by: - java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager -...</screen> - - <para>As we shall see additional libraries being defined in our - project's <filename>pom.xml</filename> file are missing:</para> - - <programlisting language="xml"><project xmlns="http://maven.apache.org/POM/4.0.0" ...> - <modelVersion>4.0.0</modelVersion> - ... - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <version>2.11.0</version> - </dependency> - ... -</project></programlisting> - </answer> - </qandaentry> - </qandadiv> - </qandaset> - - <figure xml:id="sd1_fig_mavenTest"> - <title><xref linkend="glo_Maven"/> test</title> - - <screen>> mvn test - ... -[INFO] Changes detected - recompiling the module! -[INFO] <emphasis role="red">Compiling 1 source file</emphasis> to /ma/goik/first/<emphasis - role="red">target/test-classes</emphasis> -... -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running de.hdm_stuttgart.mi.sd1.AppTest -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.567 sec -...</screen> - </figure> + <figure xml:id="sd1_fig_mavenExecute"> + <title>Execution</title> + + <screen>> cd target/classes <co linkends="sd1_fig_mavenExecute-1" + xml:id="sd1_fig_mavenExecute-1-co"/> +> java de.hdm_stuttgart.mi.sd1.App <co linkends="sd1_fig_mavenExecute-2" + xml:id="sd1_fig_mavenExecute-2-co"/> +Hello World! <co linkends="sd1_fig_mavenExecute-3" + xml:id="sd1_fig_mavenExecute-3-co"/></screen> + + <calloutlist> + <callout arearefs="sd1_fig_mavenExecute-1-co" + xml:id="sd1_fig_mavenExecute-1"> + <para>Change to base directory containing compiled <xref + linkend="glo_Java"/> classes.</para> + </callout> - <figure xml:id="sd1_fig_mavenTestFileView"> - <title>Test file view</title> + <callout arearefs="sd1_fig_mavenExecute-2-co" + xml:id="sd1_fig_mavenExecute-2"> + <para>Execute the application. Note that our + <classname>App</classname> class name is being prefixed by the + package name <package>de.hdm_stuttgart.mi.sd1</package> defined by + parameter <emphasis role="red">groupId</emphasis> in <xref + linkend="sd1_fig_mavenMiRepoCliDetails"/>.</para> + </callout> - <screen>> find . -type f - ... -./target/test-classes/de/hdm_stuttgart/mi/sd1/AppTest.class - ... -./target/surefire-reports/de.hdm_stuttgart.mi.sd1.AppTest.txt -./target/surefire-reports/TEST-de.hdm_stuttgart.mi.sd1.AppTest.xml -./target/classes/de/hdm_stuttgart/mi/sd1/App.class</screen> + <callout arearefs="sd1_fig_mavenExecute-3-co" + xml:id="sd1_fig_mavenExecute-3"> + <para>The expected output result.</para> + </callout> + </calloutlist> </figure> <figure xml:id="sd1_fig_mavenPackage"> @@ -2538,11 +2477,7 @@ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 <title>Executing <filename>first-0.9.jar</filename></title> <screen>java -jar <emphasis role="red">target/first-0.9.jar</emphasis> -Hello World! -2018-10-03 17:49:00,700 DEBUG [main] sd1.App (App.java:24) - - You may configure 'src/main/resources/log4j2.xml' -2018-10-03 17:49:00,704 DEBUG [main] sd1.App (App.java:25) - - for adapting both console and 'A1.log' file output</screen> +Hello World!</screen> </figure> <qandaset defaultlabel="qanda" xml:id="sd1_qanda_executionMechanism"> @@ -2746,12 +2681,12 @@ Generating /ma/goik/First/target/site/apidocs/help-doc.html... <itemizedlist> <listitem> <para><property>archetypeArtifactId</property>: - <option>mi-maven-archetype-quickstart</option></para> + <option>mi-maven-archetype-helloworld</option></para> </listitem> <listitem> <para><property>archetypeVersion</property>: - <option>1.1</option></para> + <option>1.2</option></para> </listitem> </itemizedlist> diff --git a/ws/Archetypes/Makefile b/ws/Archetypes/Makefile index 20ad57072040989e8dde025723a549d618090732..0ff68e7e6a66b58d88e2a63617bd00fe8102953b 100644 --- a/ws/Archetypes/Makefile +++ b/ws/Archetypes/Makefile @@ -17,7 +17,7 @@ $(M2DIR)/%/maven-metadata-local.xml:%/pom.xml #</servers> # deploy: $(foreach aType, $(ARCHETYPES), $(M2DIR)/$(aType)/maven-metadata-local.xml) archetype-catalog.xml - rsync -av --delete -e ssh index.html archetype-catalog.xml mvndeploy@maven.mi.hdm-stuttgart.de:/var/www/html/maven + rsync -av --delete -e ssh index.html archetype-catalog.xml freedocs@maven.mi.hdm-stuttgart.de:/var/www/html/maven clean: rm -rf $(foreach aType, $(ARCHETYPES), $(M2DIR)/$(aType)) diff --git a/ws/Archetypes/mi-maven-archetype-helloworld/.gitignore b/ws/Archetypes/mi-maven-archetype-helloworld/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3791e176aca0b4956df84909968d746f682ba26f --- /dev/null +++ b/ws/Archetypes/mi-maven-archetype-helloworld/.gitignore @@ -0,0 +1,52 @@ +/target/ +/.settings/ + +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + diff --git a/ws/Archetypes/mi-maven-archetype-helloworld/Readme.txt b/ws/Archetypes/mi-maven-archetype-helloworld/Readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..c18e8317d531597e7c8046853bea3a3ebb2bd24c --- /dev/null +++ b/ws/Archetypes/mi-maven-archetype-helloworld/Readme.txt @@ -0,0 +1,7 @@ +Final success via http://maven.apache.org/archetype/maven-archetype-plugin/examples/create-with-property-file.html + +Create Project from local repository using: + +mvn --batch-mode -e archetype:generate -DgroupId=de.hdm_stuttgart.mi.sd1 \ +-DartifactId=first -Dversion=0.9 -DarchetypeGroupId=de.hdm_stuttgart.mi \ +-DarchetypeArtifactId=mi-maven-archetype-helloworld -DarchetypeVersion=1.2 diff --git a/ws/Archetypes/mi-maven-archetype-helloworld/pom.xml b/ws/Archetypes/mi-maven-archetype-helloworld/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..5de886e1bbde49b620cb4de12381ebe86fd58be5 --- /dev/null +++ b/ws/Archetypes/mi-maven-archetype-helloworld/pom.xml @@ -0,0 +1,71 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <groupId>de.hdm_stuttgart.mi</groupId> + <artifactId>mi-maven-archetype-helloworld</artifactId> + <version>1.2</version> + + <packaging>maven-archetype</packaging> + + <name>MI Maven archetype helloworld</name> + + <url>https://freedocs.mi.hdm-stuttgart.de/sd1_sect_mavenCli.html</url> + + <description> + This archetype provides a minimal Java project still allowing for executable jar generation. + </description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <distributionManagement> + <repository> + <id>mi-nexus</id> + <url>https://maven.mi.hdm-stuttgart.de/nexus/repository/mi-maven</url> + </repository> + </distributionManagement> + + <build> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>3.0.1</version> + </extension> + </extensions> + + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-archetype-plugin</artifactId> + <version>3.0.1</version> + </plugin> + </plugins> + </pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>3.0.2</version> + <configuration> + <!-- Required so that .gitignore gets included in archetypes; see https://issues.apache.org/jira/browse/MRESOURCES-190 --> + <addDefaultExcludes>false</addDefaultExcludes> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.7.0</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/META-INF/maven/archetype-metadata.xml b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000000000000000000000000000000000..6b2b026fd3fdb4b84200a3ca02a4f226d4d466f5 --- /dev/null +++ b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="def" + xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="false" packaged="false" encoding="UTF-8"> + <directory/> + <includes> + <include>.gitignore</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> diff --git a/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/.gitignore b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..19d7c603173c0678aa6c06ba55fc4370bbd0b8fb --- /dev/null +++ b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/.gitignore @@ -0,0 +1,6 @@ +/target/ +/.settings/ +.classpath +.project +dependency-reduced-pom.xml +*.log diff --git a/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/Readme.md b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/Readme.md new file mode 100644 index 0000000000000000000000000000000000000000..4f905b72c6fa31903decfe284071916057e4d850 --- /dev/null +++ b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/Readme.md @@ -0,0 +1,7 @@ +Java project template +==================== + +General: +-------- +This is a very minimal »HelloWorld« style Java project. + diff --git a/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/pom.xml b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..c38b10e2746feaef1abd233787d60f41ef78f71b --- /dev/null +++ b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,75 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <packaging>jar</packaging> + + <name>${artifactId}</name> + + <url>https://freedocs.mi.hdm-stuttgart.de/sd1SectToolsOfTheTrade2.html</url> + + <description>Basic Java project.</description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.7.0</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>3.0.1</version> + <configuration> + <linksource>true</linksource> + <additionalOptions> + <additionalOption>-html5</additionalOption> + </additionalOptions> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>3.1.0</version> + <configuration> + <transformers> + <transformer + implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <manifestEntries> + <Main-Class>${package}.App</Main-Class> + </manifestEntries> + </transformer> + </transformers> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <version>3.7.1</version> + </plugin> + </plugins> + </build> +</project> diff --git a/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/src/main/java/App.java b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/src/main/java/App.java new file mode 100644 index 0000000000000000000000000000000000000000..1d444e176b044c5342484c87f06faf19b719a219 --- /dev/null +++ b/ws/Archetypes/mi-maven-archetype-helloworld/src/main/resources/archetype-resources/src/main/java/App.java @@ -0,0 +1,17 @@ +package $package; + +/** + * A simple HelloWorld style application. + */ + +public class App { + + /** + * Your application's main entry point. + * + * @param args Yet unused + */ + public static void main( String[] args ) { + System.out.println( "Hello World!" ); + } +} diff --git a/ws/Archetypes/mi-maven-archetype-quickstart/Readme.txt b/ws/Archetypes/mi-maven-archetype-quickstart/Readme.txt index 208127b5240022545398d500a91ba518773a217e..24c51b781e651bc625461833df3b93a5fa3c81da 100644 --- a/ws/Archetypes/mi-maven-archetype-quickstart/Readme.txt +++ b/ws/Archetypes/mi-maven-archetype-quickstart/Readme.txt @@ -2,7 +2,6 @@ Final success via http://maven.apache.org/archetype/maven-archetype-plugin/examp Create Project from local repository using: - mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=de.hdm-stuttgart.mi \ - -DarchetypeArtifactId=mi-maven-archetype-quickstart -DarchetypeVersion=1.1 \ - -DgroupId=de.mi.hdm_stuttgart -DartifactId=hello -DinteractiveMode=false - +mvn --batch-mode -e archetype:generate -DgroupId=de.hdm_stuttgart.mi.sd1 \ +-DartifactId=first -Dversion=0.9 -DarchetypeGroupId=de.hdm_stuttgart.mi \ +-DarchetypeArtifactId=mi-maven-archetype-quickstart -DarchetypeVersion=1.2