[英]maven dependency management from parent pom overrides ${project.version}
[英]Maven with Jenkins - Update parent pom version of dependency
我有一個類似於此的pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myApp</groupId>
<artifactId>myAppId</artifactId>
<packaging>war</packaging>
<version>1.2-SNAPSHOT</version>
<name>Maven Test Webapp</name>
<url>http://maven.apache.org</url>
<dependency>
<groupId>com.manydesigns</groupId>
<artifactId>portofino-war</artifactId>
<version>3.1.10</version>
<type>war</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>TestName</finalName>
</build>
</project>
如果我在上面的pom文件上運行'mvn release:prepare',則工件的版本會發生變化。 即它成為
<version>1.2</version>
現在讓我說我已經去了並更新了portofino-war應用程序,它是這個pom文件的依賴項。 portofino-war現在版本為3.1.11,但父pom文件指向版本3.1.10,如上所示。
如果建立了新版本的portofino-war,我有什么方法可以更新父pom(通過Maven或Jenkins)文件?
謝謝
該應用程序使用Maven覆蓋 - http://maven.apache.org/plugins/maven-war-plugin/overlays.html從其他war文件構建war文件。 這意味着如果構建了任何依賴模塊,則必須構建父模塊以生成最終war文件。
問題是,如果我構建任何模塊,我必須手動更新父pom文件中的版本,以使用正確的模塊版本進行構建。
謝謝你的幫助拉爾夫。 基本上這就是我想要實現的目標:
我想要做的是創建一個maven項目,將基於幾個模塊構建一個war文件。 假設模塊具有以下結構:
第1單元
customerModule
|-webapp
|-jsp
|-customer
|-findCustomer.jsp
|-addNewCustomer.jsp
|-deleteCustomer.jsp
|-src
|-com
|-mycompany
|-customer
|-FindCustomerAction.java
|-AddCustomerAction.java
|-DeleteCustomer.java
單詞數
productModule
|-webapp
|-jsp
|-product
|-productCustomer.jsp
|-addNewProduct.jsp
|-deleteProduct.jsp
|-src
|-com
|-mycompany
|-product
|-FindProductAction.java
|-AddProductAction.java
|-DeleteProduct.java
單詞數
commonModule
|-webapp
|-css
|-style.css
|-jsp
|-templates
|-coreTemplate.jsp
|-src
com
|-mycomany
|-common
|-Logger.java
|-Access.java
|-META-INF
|-MANIFEST.MF
|-context.xml
|-WEB-INF
|-lib
|-oraclejdbc.lib
|-log4j.lib
|-common.lib
|-struts-config.xml
|-tiles-def.xml
|-web.xml
所示的每個模塊都將由不同的團隊開發。 每個團隊生成一個war文件並將其安裝在本地maven存儲庫中。 作為示例,存儲庫可能如下所示
com
|-customerModule
|-customerModule.v2.1.war
|-customerModule.v3.0.war
|-productModule
|-productModule.v3.0.war
|-productModule.v3.1.war
|-commonModule
|-commonModule.v0.5.war
|-commonModule.v3.0.war
現在構建管理器使用上面的war文件來構建最終的可部署war文件。 我原計划使用maven疊加來合並三個war文件。 我測試了使用疊加層合並war文件,發現以下配置有效。 即使用依賴項:
注意:這些依賴項位於commonModule pom文件中
<dependency>
<groupId>com</groupId>
<artifactId>customerModule</artifactId>
<version>3.0</version>
<type>war</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com</groupId>
<artifactId>productModule</artifactId>
<version>3.1</version>
<type>war</type>
<scope>compile</scope>
</dependency>
如果我然后構建commonModule模塊,我最終得到一個war文件,其中包含Module1,Module2和Module3的所有內容。 最終結果是這樣的:
MyApp.war
|-webapp
|-css
|-style.css
|-jsp
|-customer
|-findCustomer.jsp
|-addNewCustomer.jsp
|-deleteCustomer.jsp
|-product
|-productCustomer.jsp
|-addNewProduct.jsp
|-deleteProduct.jsp
|-templates
|-coreTemplate.jsp
|-META-INF
|-MANIFEST.MF
|-context.xml
|-WEB-INF
|-lib
|-oraclejdbc.lib
|-log4j.lib
|-common.lib
|-customerModule.jar
|-productModule.jar
|-classes
|-com
|-mycomany
|-common
|-Logger.class
|-Access.class
|-struts-config.xml
|-tiles-def.xml
|-web.xml
以上工作但需要一些人工干預才能完整發布。 以下是修改模塊時會發生什么的示例
第1組更新模塊1
- Team 1 makes changes to module 1 and check in changes into CVS
- Team 1 installs module 1 onto the maven repository by issuing mvn:prepare and mvn:perform on module 1. This adds a new version of customerModule.war on to the local repository
- Team 1 updates the dependency version for module 1 in the pom file used to merge the war files (i.e. commonModule)
- Team 1 builds the deployable war file by building the commonModule.
上面沒有像你建議的那樣使用多模塊項目,所以我試圖理解版本控制如何與多模塊項目一起工作。 例如,假設多模塊項目看起來像這樣
MyApp
|- productModule
|-pom.xml
|- customerModule
|-pom.xml
|- commonModule
|-pom.xml
|-pom.xml
謝謝
對於問題“編輯”部分中描述的場景,我建議將所有war文件放在一個:multi模塊項目中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.