全部博文(89)
分类: Java
2008-09-15 21:08:35
[hantsy@localhost ~]$export M2_HOME=/opt/build/maven
[hantsy@localhost ~]$export PATH=$PATH:$M2_HOME/bin
[hantsy@localhost ~]$ mvn -v
Maven version: 2.0.9
Java version: 1.6.0_10-rc
OS name: "linux" version: "2.6.25.14-108.fc9.i686" arch: "i386" Family: "unix"
[hantsy@localhost ~]$mvn archetype:create -DgroupId=com.myapp -DartifactId=helloworld
helloworldsrc/main/java 是项目的源文件目录,src/test/java是项目的测试代码目录。pom.xml是项目的maven 配置文件,称为Project Object Model。
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- myapp
| `-- App.java
`-- test
`-- java
`-- com
`-- myapp
`-- AppTest.java
[hantsy@localhost helloworld]$mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 1 source file to /home/hantsy/Projects/helloworld/target/classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Compiling 1 source file to /home/hantsy/Projects/helloworld/target/test-classes
[INFO] [surefire:test]
[INFO] Surefire report directory: /home/hantsy/Projects/helloworld/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.myapp.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.061 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar]
[INFO] Building jar: /home/hantsy/Projects/helloworld/target/helloworld-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Thu Sep 11 19:12:32 CST 2008
[INFO] Final Memory: 7M/18M
[INFO] ------------------------------------------------------------------------
[hantsy@localhost ~]$java -cp target/helloworld-1.0-SNAPSHOT.jar com.myapp.App
Hello World!