我使用Maven的多模塊構建像下面跳過未修改模塊的maven build?
<modules>
<module>module1</module>
<module>module2</module>// dependant on module 1
<module>module3</module>// dependant on module 2
<module>warApplication</module>// its a war file dependant on above modules
</modules>
目前的生成行爲: - 如果我讓只在模塊1的變化,Maven會建連模塊2,單詞數源文件,然後把模塊1,模塊2,在warApplication/target/lib下的module3 jar文件。
當我觸發構建時,是否有配置/方式,如果沒有跳過該模塊,maven將驗證模塊下是否有任何文件被修改。對於war文件,它會把特定的 lib文件修改過來。這將節省很多時間。
要檢查是否有任何文件在模塊下被修改,maven可以存儲最後的編譯時間。在開始構建之前,它會檢查是否有任何文件在上次構建時間戳後被修改,如果是,則構建它,否則跳過它。
是否有任何maven插件可用於此?
更新: -
我的項目結構是
TopFolder
.mvn directory -> extensions.xml
build directory->build-Projects-> pom.xml
build directory-> parent -> pom.xml
modules - > module1 -> pom.xml
modules - > module2 -> pom.xml
modules - > module3 -> pom.xml
這裏是我的,包括父POM
<modules>
<module>../../modules/module1</module>
<module>../../modules/module2</module>
</modules>
模塊。我已經包括SCM標籤<developerConnection>scm:svn:https://comp.com/svn/trunk</developerConnection>
在以下兩個項目
build directory->build-Projects-> pom.xml
build directory-> parent -> pom.xml
從build directory->build-Projects-> pom.xml
建立運行所。 但問題是,當我更改任何文件的任何模塊,並從build directory-> pom.xml
運行生成,其未檢測模塊更改?
我知道,這不是一個答案,但嘗試gradle。 至少它會跳過重建未觸及的模塊。 – glebiuskv
你應該考慮即使你沒有觸及模塊2,構建的結果可能會有所不同。首先,模塊2的構建可能會因爲您更改模塊1調用的某個類而中斷。同樣,由於相同的原因,模塊2的測試可能會通過或中斷,具體取決於模塊1.此外,還存在一些較少的問題就像使用模塊2中模塊1的公共常量一樣。它們被編譯到模塊2中,因此即使您只更改了模塊1中的常量,模塊2的字節碼也可以更改。 –
@JFMeier您是對的。如果我需要也建立模塊2。但拉特的說,我肯定有沒有像這樣被改變,可以打破模塊2,有沒有辦法我可以跳過模塊2的構建 – user3198603