1. 程式人生 > >eclipse 多模組Maven專案打包指定模組

eclipse 多模組Maven專案打包指定模組

       一直在各種測試打包多模組下面的單獨模組打包,一直報找不到所依賴模組的jar包,網上各種尋找,沒有找到合適的內容,今天偶然發現有個提示要parent模組執行打包,經測試確實打包成功,記錄一下。

        在eclipse中,多模組專案中單獨打包某個web工程時,選中 "resolve workspace artifacts" 會導致war包內依賴的其他模組的jar為空目錄。 正確的打包某個模組的方式是在parent工程上執行 Run As... > Maven Build...,在Goals中輸入:

clean package -pl module_name -am
 

多模組工程的打包命令參考:

-am --also-make 同時構建所列模組的依賴模組;
-amd -also-make-dependents 同時構建依賴於所列模組的模組;
-pl --projects <arg> 構建制定的模組,模組間用逗號分隔;
-rf -resume-from <arg> 從指定的模組恢復反應堆。

看英文的更助於理解:

-am,--also-make
    If project list is specified, also build projects required by the list
	
-amd,--also-make-dependents
    If project list is specified, also build projects that depend on projects on the list
	
-pl,--projects <arg>
    Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path.

-rf,--resume-from <arg>
    Resume reactor from specified project