因為我們已經(jīng)創(chuàng)建了一個空項目,我們可以去C:\\ mvn_test \\ xmlFileEditor目錄并執(zhí)行以下mvn命令來編譯和打包項目。
c:\mvn_test\xmlFileEditor>mvn clean package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building xmlFileEditor 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom ... ... [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! [INFO] Compiling 1 source file to c:\mvn_test\xmlFileEditor\target\classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ xmlFileEditor --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory c:\mvn_test\xmlFileEditor\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ xmlFileEditor --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! [INFO] Compiling 1 source file to c:\mvn_test\xmlFileEditor\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ xmlFileEditor --- [INFO] Surefire report directory: c:\mvn_test\xmlFileEditor\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.java2s.ide.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ xmlFileEditor --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 35.354 s [INFO] Finished at: 2014-11-03T16:14:01-08:00 [INFO] Final Memory: 25M/369M [INFO] ------------------------------------------------------------------------ c:\mvn_test\xmlFileEditor>
我們建立了我們的項目并創(chuàng)建了最終的jar文件。
從上面的命令我們可以看到兩個目標可以結(jié)合起來一個命令。
首先,我們可以用 clean
goal清除目標目錄然后將項目構(gòu)建輸出打包為具有 package
目標的jar。
打包的jar在xmlFileEditor \\ target文件夾中可用為 xmlFileEditor-1.0-SNAPSHOT.jar
。
測試報告可在xmlFileEditor \\ target \\ surefire-reports文件夾中找到。
Maven編譯源代碼文件,然后測試源代碼文件。然后Maven運行測試用例。 最后Maven創(chuàng)建了包。
更多建議: