问题描述
我有一个POM文件,类似于此
I have a pom file that looks similar to this
<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释放prepare'的人为改变的版本。即它成为
If i run 'mvn release:prepare' on the above pom file, the version of the artifact changes. i.e. it becomes
<version>1.2</version>
现在可以说,我已经和更新柏涛战应用程序,它是这个POM文件的依赖关系。菲诺港战现在是3.1.11版本,但父POM文件指向3.1.10以上版本,如图所示。
Now lets say i have gone and updated the portofino-war application which is a dependency of this pom file. portofino-war is now at version 3.1.11 but the parent pom file points to version 3.1.10 as shown above.
有什么办法,我可以更新父POM(通过Maven的詹金斯或)如果菲诺港战争的新版本是建立文件?
Is there any way i can update the parent pom (either via Maven or Jenkins) file if a new version of portofino-war is built?
感谢
该应用程序使用Maven的覆盖 - 建立从其他战争文件的war文件。这意味着,如果任何从属模块被建成,在父模块待建以产生最终战争文件
The application uses Maven overlays - http://maven.apache.org/plugins/maven-war-plugin/overlays.html to build a war file from other war files. This means that if any of the dependent modules are built, the parent module has to be built to produce the final war file.
问题是在如果我构建任何模块的那一刻,我必须手动更新父POM文件中的版本使用正确的模块版本来构建。
The problem is that at the moment if i build any of the modules, i have to manually update the version in the parent pom file to build using the correct module version.
感谢您的帮助拉尔夫。基本上,这就是我想达到什么样的:
Thanks for your help Ralph. Basically this is what i would like to achieve:
我所要做的是创建一个Maven项目,将建立基于几个模块战争文件。假设模块具有以下结构:
What i am trying to do is create a maven project that will build a war file based on several modules. Assume the modules have the following structure:
模块1
customerModule
|-webapp
|-jsp
|-customer
|-findCustomer.jsp
|-addNewCustomer.jsp
|-deleteCustomer.jsp
|-src
|-com
|-mycompany
|-customer
|-FindCustomerAction.java
|-AddCustomerAction.java
|-DeleteCustomer.java
模块2
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仓库。作为一个例子库可能看起来像这样
Each of the modules shown will be developed by a different team. Each team produces a war file and installs it in the local maven repository. As an example the repository could look like this
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文件。我本来打算用maven叠加合并三战文件。我做了测试战争文件,覆盖了合并,发现下面的配置工作。即使用依赖关系:
Now the build manager uses the above war files to build the final deployable war file. I was originally planning to use maven overlays to merge the three war files. I did test the merging of war files with overlays and found that the following configuration worked. i.e. using dependencies:
请注意:这些依赖于commonModule POM文件
Note: These dependencies are in the commonModule pom file
<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模块,我结束了一个包含模块1,模块2和单词数的全部内容之一war文件。它与像这样结束:
If i then build the commonModule module, i end up with one war file that contains all the contents of Module1, Module2 and Module3. Which ends up with something like this:
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
以上的作品,但需要一个完整的版本有点人工干预。这里是一个模块是否被修改会发生什么,一个例子
The above works but requires a bit of manual intervention for a full release. Here is an example of what would happen if a module is modified
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.
如你所说,所以我想了解如何将版本多模块项目工作中没有使用多模块项目。例如,可以说多模块项目看起来像这样
The above does not use a multi module project as you suggested so i am trying to understand how the versioning would work with multi module projects. For example, lets say the multi module project will look like this
MyApp
|- productModule
|-pom.xml
|- customerModule
|-pom.xml
|- commonModule
|-pom.xml
|-pom.xml
- 是在什么相比,只是就吃父版本号增加每个孩子模块中的版本号不同?
- 您说,子模块将使用父版本。比方说父版本是目前3.4版本,它怎么会知道它是应该使用productModule.war? 3.1版本
- 最后,如果队1已进行了更改子模块之一,将他们仍然需要首先构建多模块项目之前建立它并部署到Maven仓库作为一个单独的产品或可这为一步完成?
- 这将如何工作,如果我想打一个补丁版本,这并不一定意味着使用最新版本的特定模块的?
- What is the difference in adding the version number in each child module compared to just havin the version number on the parent?
- You say that the child modules will use the parent version. Lets say the parent version is currently version 3.4, how will it know that it is supposed to use version 3.1 of the productModule.war?
- And finally, if team 1 has made a change to one of the child modules, would they still need to build it and deploy it on to the maven repository as an individual product first before building the multi-module project or can this be done as one step?
- How would this work if i want to make a patch release that does not necessarily mean using the latest version of a specific module?
感谢
推荐答案
有关问题中的编辑部分中描述的情况下,我建议把所有战争的文件在一个单一的:多模块项目
For the scenario described in the "Edit" part of the question, I would recommend to put all war files in a single: multi module project.
这篇关于与詹金斯Maven的 - 依赖更新父POM版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!