diff --git a/Doc/Sd1/gettingStarted.xml b/Doc/Sd1/gettingStarted.xml index 3dd892fee1247af45cf579080b3bf9b0fad407b7..eabc064c25280747e65bbf84512906e90ce6daa3 100644 --- a/Doc/Sd1/gettingStarted.xml +++ b/Doc/Sd1/gettingStarted.xml @@ -792,18 +792,17 @@ loop # 12</programlisting> <para>Test your configuration by creating a dummy project using the command line (copy and paste to a shell window):</para> - <programlisting language="bash">mvn -DinteractiveMode=false \ + <programlisting language="bash">mvn -e archetype:generate \ +-DinteractiveMode=false \ -DgroupId=de.hdm_stuttgart.mi.sd1 \ --DartifactId=test -Dversion=1.0 -DarchetypeGroupId=de.hdm-stuttgart.mi \ --DarchetypeArtifactId=mi-maven-archetype-quickstart -DarchetypeVersion=1.1 \ --DarchetypeRepository=https://maven.mi.hdm-stuttgart.de/Archetypes \ -org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate</programlisting> +-DartifactId=gettingstarted -Dversion=0.9 -DarchetypeGroupId=de.hdm-stuttgart.mi \ +-DarchetypeArtifactId=mi-maven-archetype-quickstart -DarchetypeVersion=1.1</programlisting> <para>This should result in the following output:</para> <programlisting language="bash">goik@hopc tmp> mvn -DinteractiveMode=false \ -DgroupId=de.hdm_stuttgart.mi.sd1 \ --DartifactId=test -Dversion=1.0 -DarchetypeGroupId=de.hdm-stuttgart.mi \ +-DartifactId=gettingstarted -Dversion=1.0 -DarchetypeGroupId=de.hdm-stuttgart.mi \ -DarchetypeArtifactId=mi-maven-archetype-quickstart -DarchetypeVersion=1.1 \ -DarchetypeRepository=https://maven.mi.hdm-stuttgart.de/Archetypes \ org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate @@ -814,8 +813,8 @@ org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate ... [INFO] Parameter: version, Value: 1.0 [INFO] Parameter: groupId, Value: de.hdm_stuttgart.mi.sd1 -[INFO] Parameter: artifactId, Value: test -[INFO] Project created from Archetype in dir: /ma/goik/tmp/test +[INFO] Parameter: artifactId, Value: gettingstarted +[INFO] Project created from Archetype in dir: /ma/goik/tmp/gettingstarted [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ @@ -824,14 +823,211 @@ org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate [INFO] Final Memory: 16M/164M</programlisting> <para>This creates a dummy project folder named - <filename>test</filename>.</para> + <filename>gettingstarted</filename>.</para> </listitem> </orderedlist> <para>You are now prepared to create <xref linkend="glo_Maven"/> from inside the <productname xlink:href="https://www.jetbrains.com/idea">IntelliJ IDEA</productname> - <xref linkend="glo_IDE"/>.</para> + <xref linkend="glo_IDE"/>. We provide some explanation details regarding + the above command:</para> + + <programlisting language="none"><command>mvn</command> -e archetype:generate <co + linkends="sd1CalloutMavenCmdLine-1" + xml:id="sd1CalloutMavenCmdLine-1-co"/> \ + -DarchetypeGroupId=de.hdm-stuttgart.mi -DarchetypeArtifactId=mi-maven-archetype-quickstart <co + linkends="sd1CalloutMavenCmdLine-3" + xml:id="sd1CalloutMavenCmdLine-3-co"/>\ + -DgroupId=de.hdm_stuttgart.mi.sd1 <co linkends="sd1CalloutMavenCmdLine-4" + xml:id="sd1CalloutMavenCmdLine-4-co"/> \ + -DartifactId=gettingstarted <co linkends="sd1CalloutMavenCmdLine-4" + xml:id="sd1CalloutMavenCmdLine-5-co"/> \ + -Dversion=0.9 <co linkends="sd1CalloutMavenCmdLine-6" + xml:id="sd1CalloutMavenCmdLine-6-co"/> \ + -DinteractiveMode=false <co linkends="sd1CalloutMavenCmdLine-7" + xml:id="sd1CalloutMavenCmdLine-7-co"/></programlisting> + + <calloutlist> + <callout arearefs="sd1CalloutMavenCmdLine-1-co" + xml:id="sd1CalloutMavenCmdLine-1"> + <para>Create a <xref linkend="glo_Maven"/> project using an + archetype.</para> + </callout> + + <callout arearefs="sd1CalloutMavenCmdLine-3-co" + xml:id="sd1CalloutMavenCmdLine-3"> + <para>The archetype's unique name within the repository.</para> + </callout> + + <callout arearefs="sd1CalloutMavenCmdLine-4-co sd1CalloutMavenCmdLine-5-co" + xml:id="sd1CalloutMavenCmdLine-4"> + <para>The parameters <property>archetypeGroupId</property> and + <property>archetypeArtifactId</property> will define e.g. the + generated project's default base package to be explained in <xref + linkend="sw1ChapterObjectsClasses"/>.</para> + </callout> + + <callout arearefs="sd1CalloutMavenCmdLine-6-co" + xml:id="sd1CalloutMavenCmdLine-6"> + <para>The generated project's version.</para> + </callout> + + <callout arearefs="sd1CalloutMavenCmdLine-7-co" + xml:id="sd1CalloutMavenCmdLine-7"> + <para>During project generation <xref linkend="glo_Maven"/> shall work + in batch mode not asking for user input.</para> + </callout> + </calloutlist> + + <para>Entering the project allows for compiling, testing and installing. + The latter obviously is not very useful until a sensible implementation + has been added:</para> + + <glosslist> + <glossentry> + <glossterm><command>mvn</command> <option>compile</option></glossterm> + + <glossdef> + <programlisting language="none">goik@mi-ESPRIMO-P910 gettingstarted> mvn compile +[INFO] Scanning for projects... +[INFO] +[INFO] ------------------------------------------------------------------------ +[INFO] Building gettingstarted 0.9 +[INFO] ------------------------------------------------------------------------ +[INFO] +[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ gettingstarted --- +[INFO] Using 'UTF-8' encoding to copy filtered resources. +[INFO] Copying 1 resource +[INFO] +[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ gettingstarted --- +[INFO] Nothing to compile - all classes are up to date +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 0.552s +[INFO] Finished at: Sun Apr 10 20:01:01 CEST 2016</programlisting> + </glossdef> + </glossentry> + + <glossentry> + <glossterm><command>mvn</command> <option>test</option></glossterm> + + <glossdef> + <programlisting language="none">goik@mi-ESPRIMO-P910 gettingstarted> mvn test +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +... +[INFO] Surefire report directory: /ma/goik/gettingstarted/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running my.base.url.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.045 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------</programlisting> + </glossdef> + </glossentry> + + <glossentry> + <glossterm xml:id="glosstermSd1MvnInstall"><command>mvn</command> + <option>install</option></glossterm> + + <glossdef> + <programlisting language="none">goik@mi-ESPRIMO-P910 gettingstarted> mvn install +[INFO] Scanning for projects... +... +[INFO] +[INFO] --- maven-install-plugin:2.3:install (default-install) @ gettingstarted --- +[INFO] Installing ../target/<filename>gettingstarted-0.9.jar</filename> to + /ma/goik/.m2/repository/my/base/url/gettingstarted/0.9/gettingstarted-0.9.jar</programlisting> + + <para>Notice the installation of + <filename>gettingstarted-0.9.jar</filename> to the user's local + <xref linkend="glo_Maven"/> cached repository.</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>Execution</glossterm> + + <glossdef> + <para>By default our <xref linkend="glo_Maven"/> generated file + <filename>gettingstarted-0.9.jar</filename> (See <xref + linkend="glosstermSd1MvnInstall"/>) is an <link + xlink:href="https://www.mkyong.com/java/how-to-make-an-executable-jar-file">executable + jar archive</link>. The <command>java</command> command allows for + execution:</para> + + <programlisting language="bash">java -jar target/gettingstarted-0.9.jar +Hello World! +2017-06-02 16:06:14,901 DEBUG [main] sd1.App (App.java:21) - With respect to logging you may want to configure file +2017-06-02 16:06:14,903 DEBUG [main] sd1.App (App.java:22) - 'src/main/resources/log4j2.xml' to suit your needs. +2017-06-02 16:06:14,903 DEBUG [main] sd1.App (App.java:23) - This config file 'log4j2.xml' will result in 'A1.log' +2017-06-02 16:06:14,903 DEBUG [main] sd1.App (App.java:24) - file containing logging output as well.</programlisting> + + <para>This corresponds to a class + <filename>src/main/java/de/hdm_stuttgart/mi/sd1/App.java</filename> + belonging to the archetype:</para> + + <programlisting language="java">package de.hdm_stuttgart.mi.sd1; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +/** + * A simple http://logging.apache.org/log4j/2.x demo, + * see file log4j2.xml for configuration options. + * + */ +public class App { + private static Logger log = LogManager.getLogger(App.class); + + /** + * @param args Unused + */ + public static void main( String[] args ) { + System.out.println( "Hello World!" ); + + log.debug("With respect to logging you may want to configure file "); + log.debug("'src/main/resources/log4j2.xml' to suit your needs."); + log.debug("This config file 'log4j2.xml' will result in 'A1.log'"); + log.debug("file containing logging output as well."); + } +}</programlisting> + + <para>We will get a deeper understanding of these code lines when + advancing this lecture.</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm><command>mvn</command> <option>clean</option></glossterm> + + <glossdef> + <programlisting language="none">goik@mi-ESPRIMO-P910 gettingstarted> mvn clean +[INFO] Scanning for projects... +[INFO] +[INFO] ------------------------------------------------------------------------ +[INFO] Building gettingstarted 0.9 +[INFO] ------------------------------------------------------------------------ +[INFO] +[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ gettingstarted --- +[INFO] Deleting /ma/goik/gettingstarted/target</programlisting> + + <para>This will effectively clean up all generated + <filename>*.class</filename> files.</para> + </glossdef> + </glossentry> + </glosslist> <section xml:id="sd1FirstJavaProject"> <title>Your first project</title> diff --git a/Doc/Sd1/objectsClasses.xml b/Doc/Sd1/objectsClasses.xml index b802305cd01be59fbd31a3f6404c6318f825c013..df93a15ca2b13aac996ce7082b382fa2457e04e4 100644 --- a/Doc/Sd1/objectsClasses.xml +++ b/Doc/Sd1/objectsClasses.xml @@ -471,204 +471,6 @@ Generating /ma/goik/Downloads/Exam/target/site/apidocs/help-doc.html... </section> </section> - <section xml:id="sd1SectUsingMavenIntellij"> - <title>Preliminaries: Using <xref linkend="glo_Maven"/> with <xref - linkend="glo_Soft_IntellijIDEA"/></title> - - <para><xref linkend="glo_Soft_IntellijIDEA"/> requires a plugin for - importing supplementary <xref linkend="glo_Maven"/> archetypes:</para> - - <blockquote> - <para>Download <link - xlink:href="https://plugins.jetbrains.com/plugin/7965">Maven Archetype - Catalogs plugin</link></para> - </blockquote> - - <para>The Installation itself requires the - <filename>maven-archetypes-catalog-plugin-XXX.zip</filename> plugin - <filename>.zip</filename> file mentioned in the above link:</para> - - <mediaobject> - <imageobject> - <imagedata fileref="Ref/Fig/mavenArchetypesIntellijPlugin.png"/> - </imageobject> - </mediaobject> - - <para>You may no add the supplementary MI Maven archetype catalog <uri - xlink:href="https://maven.mi.hdm-stuttgart.de/archetype-catalog.xml">https://maven.mi.hdm-stuttgart.de/archetype-catalog.xml</uri>:</para> - - <mediaobject> - <imageobject> - <imagedata fileref="Ref/Fig/mavenMiArchetypesIntellij.png"/> - </imageobject> - </mediaobject> - </section> - - <section xml:id="sd1SectUsingMavenShell"> - <title>Preliminaries: Using <xref linkend="glo_Maven"/> from the command - line</title> - - <para><xref linkend="glo_Soft_Eclipse"/> is actually not required for - <xref linkend="glo_Maven"/> based development. We may create <xref - linkend="glo_Maven"/> projects starting from a command prompt:</para> - - <programlisting language="none"><command>mvn</command> -e archetype:generate <co - linkends="sd1CalloutMavenCmdLine-1" - xml:id="sd1CalloutMavenCmdLine-1-co"/> \ - -DarchetypeCatalog=https://maven.mi.hdm-stuttgart.de/archetype-catalog.xml <co - linkends="sd1CalloutMavenCmdLine-2" - xml:id="sd1CalloutMavenCmdLine-2-co"/>\ - -DarchetypeGroupId=de.hdm-stuttgart.mi -DarchetypeArtifactId=mi-maven-archetype-quickstart <co - linkends="sd1CalloutMavenCmdLine-3" - xml:id="sd1CalloutMavenCmdLine-3-co"/>\ - -DgroupId=my.base.url <co linkends="sd1CalloutMavenCmdLine-4" - xml:id="sd1CalloutMavenCmdLine-4-co"/> \ - -DartifactId=gettingstarted <co linkends="sd1CalloutMavenCmdLine-4" - xml:id="sd1CalloutMavenCmdLine-5-co"/> \ - -Dversion=0.9 <co linkends="sd1CalloutMavenCmdLine-6" - xml:id="sd1CalloutMavenCmdLine-6-co"/> \ - -DinteractiveMode=false <co linkends="sd1CalloutMavenCmdLine-7" - xml:id="sd1CalloutMavenCmdLine-7-co"/></programlisting> - - <calloutlist> - <callout arearefs="sd1CalloutMavenCmdLine-1-co" - xml:id="sd1CalloutMavenCmdLine-1"> - <para>Create a <xref linkend="glo_Maven"/> project using an - archetype.</para> - </callout> - - <callout arearefs="sd1CalloutMavenCmdLine-2-co" - xml:id="sd1CalloutMavenCmdLine-2"> - <para>Since our MI <xref linkend="glo_Maven"/> archetypes are not - publicly available we must indicate the archetype's repository <xref - linkend="glo_URL"/> explicitly. You may omit the trailing - <filename>archetype-catalog.xml</filename> component which will be - searched for implicitly.</para> - </callout> - - <callout arearefs="sd1CalloutMavenCmdLine-3-co" - xml:id="sd1CalloutMavenCmdLine-3"> - <para>The archetype's unique name within the repository.</para> - </callout> - - <callout arearefs="sd1CalloutMavenCmdLine-4-co sd1CalloutMavenCmdLine-5-co" - xml:id="sd1CalloutMavenCmdLine-4"> - <para>The parameters <property>archetypeGroupId</property> and - <property>archetypeArtifactId</property> will define e.g. the - generated project's default base package.</para> - </callout> - - <callout arearefs="sd1CalloutMavenCmdLine-6-co" - xml:id="sd1CalloutMavenCmdLine-6"> - <para>The generated project's version.</para> - </callout> - - <callout arearefs="sd1CalloutMavenCmdLine-7-co" - xml:id="sd1CalloutMavenCmdLine-7"> - <para>During project generation <xref linkend="glo_Maven"/> shall work - in batch mode not asking for user input.</para> - </callout> - </calloutlist> - - <para>Entering the project allows for compiling, testing and installing. - The latter obviously is not very useful until a sensible implementation - has been added:</para> - - <glosslist> - <glossentry> - <glossterm><command>mvn</command> <option>compile</option></glossterm> - - <glossdef> - <programlisting language="none">goik@mi-ESPRIMO-P910 gettingstarted> mvn compile -[INFO] Scanning for projects... -[INFO] -[INFO] ------------------------------------------------------------------------ -[INFO] Building gettingstarted 0.9 -[INFO] ------------------------------------------------------------------------ -[INFO] -[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ gettingstarted --- -[INFO] Using 'UTF-8' encoding to copy filtered resources. -[INFO] Copying 1 resource -[INFO] -[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ gettingstarted --- -[INFO] Nothing to compile - all classes are up to date -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 0.552s -[INFO] Finished at: Sun Apr 10 20:01:01 CEST 2016</programlisting> - </glossdef> - </glossentry> - - <glossentry> - <glossterm><command>mvn</command> <option>test</option></glossterm> - - <glossdef> - <programlisting language="none">goik@mi-ESPRIMO-P910 gettingstarted> mvn test -[INFO] Scanning for projects... -[INFO] ------------------------------------------------------------------------ -... -[INFO] Surefire report directory: /ma/goik/gettingstarted/target/surefire-reports - -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running my.base.url.AppTest -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.045 sec - -Results : - -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 - -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------</programlisting> - </glossdef> - </glossentry> - - <glossentry> - <glossterm><command>mvn</command> <option>install</option></glossterm> - - <glossdef> - <programlisting language="none">goik@mi-ESPRIMO-P910 gettingstarted> mvn install -[INFO] Scanning for projects... -... -[INFO] -[INFO] --- maven-install-plugin:2.3:install (default-install) @ gettingstarted --- -[INFO] Installing .../<filename>gettingstarted-0.9.jar</filename> to /ma/goik/.m2/repository/my/base/url/gettingstarted/0.9/gettingstarted-0.9.jar</programlisting> - - <para>Notice the installation of - <filename>gettingstarted-0.9.jar</filename> to the user's local - <xref linkend="glo_Maven"/> cached repository.</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm><command>mvn</command> <option>clean</option></glossterm> - - <glossdef> - <programlisting language="none">goik@mi-ESPRIMO-P910 gettingstarted> mvn clean -[INFO] Scanning for projects... -[INFO] -[INFO] ------------------------------------------------------------------------ -[INFO] Building gettingstarted 0.9 -[INFO] ------------------------------------------------------------------------ -[INFO] -[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ gettingstarted --- -[INFO] Deleting /ma/goik/gettingstarted/target</programlisting> - - <para>This will effectively clean up all generated - <filename>*.class</filename> files. If you used to work on an <xref - linkend="glo_Soft_Eclipse"/> project you may want to use - <command>mvn</command> <option>clean eclipse:clean</option>. This - removes files like <filename>.project</filename> and - <filename>.classpath</filename> along with the - <filename>.settings</filename> subdirectory.</para> - </glossdef> - </glossentry> - </glosslist> - </section> - <section xml:id="sd1SectCreatingAnObject"> <title>Creating An Object</title>