diff --git a/Doc/Sd1/appendix.xml b/Doc/Sd1/appendix.xml index 5c5785ee3051e81926a1e26e723e2584c5e4889d..8c7ba2d0785c3edc5486db183c73af082bb6f514 100644 --- a/Doc/Sd1/appendix.xml +++ b/Doc/Sd1/appendix.xml @@ -455,28 +455,98 @@ inputSecond.txt</programlisting> </plugin></programlisting> <para>Running <command>mvn</command> <option>install</option> will - create an executable jar file + create an executable jar file like e.g. <filename>~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar</filename> - with <quote>~</quote> denoting your home directory. You may then - create a simple shell wrapper script <filename>mygrep</filename> - (don't forget to supply execute permission) hiding the - <command>java</command> execution stuff:</para> - - <programlisting language="none">#!/bin/sh - -# A simple wrapper hiding java execution stuff. - -# Do not forget to make this file executable by issuing "chmod ugo+x mygrep" - -java -jar ~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar $* - -#end</programlisting> - - <para>You my now simply invoke your application. The following - example reads from standard input by virtue of a pipe:</para> - - <programlisting language="none">> cat Testdata/input.txt | ./bin/mygrep red + with <quote>~</quote> denoting your home directory:</para> + + <programlisting language="none">> mvn install +[INFO] Scanning for projects... +[INFO] +[INFO] ------------------------------------------------------------------------ +[INFO] Building grep 0.9 +[INFO] ------------------------------------------------------------------------ + +... +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running de.hdm_stuttgart.mi.sd1.grep.CommandLineTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.757 sec + +Results : + +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 + +... +[INFO] Installing /home/goik/workspace/sd-project-summer/grep/target/grep-0.9.jar to + /home/goik/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar +... +</programlisting> + + <para>Due to our + <code><Main-Class>de.hdm_stuttgart.mi.sd1.grep.Grep</Main-Class></code> + declaration in <filename>pom.xml</filename> this jar file is + executable:</para> + + <programlisting language="none">> java -jar ~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar +No search string given +Usage: grep [-i] [-l] searchString [file 1] [file 2] ...</programlisting> + + <para>There are further simplification steps:</para> + + <orderedlist> + <listitem> + <para>When making the jar file executable using <command + xlink:href="http://linux.die.net/man/1/chmod">chmod</command> + we can omit the <command>java</command> command:</para> + + <programlisting language="none">> chmod +x ~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar +> ~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar +No search string given +Usage: grep [-i] [-l] searchString [file 1] [file 2] ...</programlisting> + + <para>Notice <quote>~</quote> representing a user's home + directory.</para> + </listitem> + + <listitem> + <para>We may copy the jar archive to a standard location + containing executable commands:</para> + + <programlisting language="none">> mkdir bin +> +> cp ~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar ~/bin/jgrep +> +> ~/bin/jgrep +No search string given +Usage: grep [-i] [-l] searchString [file 1] [file 2] ...</programlisting> + </listitem> + + <listitem> + <para>We may add this directory to the set of directories + being searched by the operating system's command line + interpreter for executable commands. This is being achieved by + either creating or modifying a file + <filename>~/.profile</filename> in the user's home directory + using a plain text editor. The file should contain:</para> + + <programlisting language="none">PATH="$HOME/bin:$PATH"</programlisting> + + <para>After logging out and on again your PATH environment + variable should contain your <filename>~/bin</filename> + component:</para> + + <programlisting language="none">> echo $PATH +<emphasis role="bold">/home/goik/bin</emphasis>:/usr/local/sbin:/usr/local/bin:/usr/...</programlisting> + + <para>You should now be able to call <command>jgrep</command> + from arbitrary filesystem locations:</para> + + <programlisting language="none">> cd Desktop/ +> cat Testdata/input.txt | ./bin/mygrep red The red cross acts worldwide</programlisting> + </listitem> + </orderedlist> </listitem> <listitem xml:id="sd1ProjectGrepUnitTestingHint">