> mvn package
C:\Users\mlavannis\workspace-confucius>cd HelloWorldJARArch
C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWorldJARArch 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ HelloWorldJARArch ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ HelloWorldJARArch ---
[INFO] Compiling 1 source file to C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ HelloWorldJARArch ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ HelloWorldJARArch ---
[INFO] Compiling 1 source file to C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ HelloWorldJARArch ---
[INFO] Surefire report directory: C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.confucius.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.033 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ HelloWorldJARArch ---
[INFO] Building jar: C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\target\HelloWorldJARArch-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.240s
[INFO] Finished at: Tue Mar 13 21:51:37 EDT 2012
[INFO] Final Memory: 9M/16M
[INFO] ------------------------------------------------------------------------
C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch>
Maven will follow the instructions in the project's pom.xml to build the jar.
After the build is complete, you will see a /target folder in which you will see HelloWorldJARArch-1.0-SNAPSHOT.jar
Maven always adds the version number to the final target.
If you only wanted to run the tests, and not actually build the jar, you would give the command:
> mvn test
C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch>mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloWorldJARArch 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ HelloWorldJARArch ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ HelloWorldJARArch ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ HelloWorldJARArch ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ HelloWorldJARArch ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ HelloWorldJARArch ---
[INFO] Surefire report directory: C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.confucius.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.916s
[INFO] Finished at: Tue Mar 13 21:55:13 EDT 2012
[INFO] Final Memory: 3M/7M
[INFO] ------------------------------------------------------------------------
C:\Users\mlavannis\workspace-confucius\HelloWorldJARArch>
You can add as many classes as you want in the /src/main/java folder, and they will all get automatically packaged into the HelloWorldJARArch-1.0-SNAPSHOT.jar when you run mvn package - no configuration necessary.
Similarly, you can write as many junit tests as you like in /src/test/java and they will be automatically executed when you run mvn test
By using the conventions of the JAR archetype, we have simplified our build process, in fact we have made it configuration-free.
No comments:
Post a Comment