maven多模塊profiles的石使用


另外參考:https://blog.csdn.net/linhao19891124/article/details/73872303

maven中指定build一個project中幾個特定的子modules

問題由來:

      一個項目可能會有多個子module,在特定情況下可能只需要build其中幾個module。

例如我的項目的目錄結構如下

myproject

|------------module_one

|------------module_two

|------------module_three

|------------module_four

|------------module_five

|------------module_six

|------------module_seven

|------------pom.xml

解決方法一:

例:我想要build module_three,module_five,module_seven三個子module

在根pom同一級目錄運行如下命令:

mvn clean install -pl module_three,module_five,module_seven

也可以在此命令上加上以下參數

-am 不僅build module_three,module_five,module_seven這三個,而且build這些子module require的其他項目,require是指其parent項目。

-amd 不僅build module_three,module_five,module_seven這三個,而且build依賴這三個module的項目,如module_other。

 

解決方法二:

增加一個profile,如:

復制代碼
<profiles>      
  <profile>
            <id>patch_001</id>
            <properties>
                
            </properties>
            <modules>
                <module>module_three</module>
                <module>module_five</module>
                <module>module_seven</module>
            </modules>
        </profile>
</profiles>
復制代碼

然后運行maven命令:

mvn clean install -Ppatch_001  #這樣也可以只build這三個子module

PS:我采用第二種方法的時候,發現在profile這樣定義了所要build的module后,外面就不能再定義需要build的module了,否則就會按照外面定義的來build一系列,不知道是什么原因,或者是我的寫法有錯誤,如果有哪位大神知道,還望不吝賜教。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM