问题描述
在我们的项目中,我们大约有25个Maven项目,其中每个项目至少包含3个模块项目和一个父POM.这样一来,总共约有(25 * 4)100个POM文件.有什么简单的方法可以维护POM更改版本?因此,这项任务变得乏味而无聊.这一定是整个软件开发中的常见问题吗?
In our projects, we have about 25 maven projects and each one of them contains at least 3 module projects and one parent POM. So total is around (25 *4) 100 POM files. Is there any easy way to maintain POM change version ? So this task become tedious and boring task. This must be common problem across the Software Development ?
有人有脚本或工具来更改此版本以处理以下3种情况吗?
Does anyone have scripts or tool to do this version change to handle following 3 cases ?
1)
<dependency>
<groupId>THEGROUPID</groupId>
<artifactId>THEARTIFACT</artifactId>
<version>THE-VERSION</version>
</dependency>
2)
<dependency>
<groupId>THEGROUPID</groupId>
<artifactId>THEARTIFACT</artifactId>
<version>$(version.number)</version>
</dependency>
3)
<parent>
<groupId>THEGROUPID</groupId>
<artifactId>THEARTIFACT</artifactId>
<version>THE-VERSION</version>
</parent>
我们有25个Maven项目,并且每个项目之间相互依赖(通过父pom,但没有循环依赖).因此,当我们更改其中一个库的版本时,需要在所有Maven模块父POM中进行更改.....因此,我一直在寻找能够在众多POM中实现这一目标的工具,而不仅仅是一个muti. -module项目(发行插件将仅发行和一个maven muti-module项目.)我希望这将对问题有更好的了解.
We have 25 maven projects and each one have on each other (via parent pom but not cyclic dependency) dependency, between them. So When we change a version of one of the lib, it needs to be changed throughout out all the maven module parent POMs..... Hence, I was looking for tool that can achieve this across the rage of POMs not just one muti-module project (release plug-in will only release and ONE maven muti-module project.) I hope this will have better understanding of the problem..
基本上,我正在寻找linux SED类型的命令,但要查找特定的groupid和artifactid.
Basically, I am looking for linux SED type of command but for specific groupid and artifactid.
谢谢
Bmis13
推荐答案
将所有版本放入父pom的<dependencyManagement>
中:
Put all the versions in the <dependencyManagement>
in your parent pom:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>THEGROUPID</groupId>
<artifactId>THEARTIFACT</artifactId>
<version>THE-VERSION</version>
</dependency>
</dependencies>
</dependencyManagement>
这里,您不需要将<version>
标记添加到子poms中.
Hereby, you do not need to add the <version>
tag to your child poms.
参考: dependencyManagement (向下滚动)
这篇关于适用于多个Maven项目的Maven POM版本管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!