Maven命令行使用:mvn clean package(打包)

先把命令行切換到Maven項目的根目錄,好比:/d/xxxwork/java/maven-test,而後執行命令:java

 mvn clean package

執行結果以下:安全

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building rtp-front 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rtp-front ---
[INFO] Deleting D:\xxxwork\Java\maven-test\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rtp-front ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ rtp-front ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 13 source files to D:\CtripWork\Java\maven-test\target\classes
[WARNING] /D:/xxxwork/Java/maven-test/src/main/java/ReadOnly.java: 某些輸入文件使用了未經檢查或不安全的操做。
[WARNING] /D:/xxxwork/Java/maven-test/src/main/java/ReadOnly.java: 有關詳細信息, 請使用 -Xlint:unchecked 從新編譯。
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rtp-front ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\xxxwork\Java\maven-test\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ rtp-front ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rtp-front ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ rtp-front ---
[INFO] Building jar: D:\xxxwork\Java\maven-test\target\rtp-front-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.284 s
[INFO] Finished at: 2016-11-14T15:36:55+08:00
[INFO] Final Memory: 15M/77M
[INFO] ------------------------------------------------------------------------

 執行順序:maven

一、使用清理插件:maven-clean-plugin:2.5執行清理刪除已有target目錄(版本2.5);測試

二、使用資源插件:maven-resources-plugin:2.6執行資源文件的處理(版本2.6);ui

三、使用編譯插件:maven-compiler-plugin:3.1編譯全部源文件生成class文件至target\classes目錄下(版本3.1);spa

四、使用資源插件:maven-resources-plugin:2.6執行測試資源文件的處理(版本2.6);插件

五、使用編譯插件:maven-compiler-plugin:3.1編譯測試目錄下的全部源代碼(版本3.1);命令行

六、使用插件:maven-surefire-plugin:2.12運行測試用例(版本2.12);code

七、使用插件:maven-jar-plugin:2.4對編譯後生成的文件進行打包,包名稱默認爲:artifactId-version,好比本例生成的jar文件:rtp-front-1.0-SNAPSHOT,包文件保存在target目錄下(這個生成的包不能在命令行中直接執行,由於咱們尚未入口類配置到Manifest資源配置文件中去,後續會闡述)。orm

備註:

無論是compile、package仍是install等前三個步驟都是必不可少的。

相關文章
相關標籤/搜索