在Maven项目中,如何自动更新所有子模块以及父模块的版本? [英] In a Maven project, how can I automatically update the version all child modules, plus the parent?
问题描述
我有一个多模块项目.
I have a multi-module project.
parent POM (1.0-SNAPSHOT)
|-- module1 (1.0-SNAPSHOT)
|-- module2 (1.0-SNAPSHOT)
`-- module3 (1.0-SNAPSHOT)
当我执行mvn release:prepare时,请验证父POM具有SNAPSHOT版本,并且所有相关模块都没有SNAPSHOT版本.如何自动将所有子模块从SNAPSHOT更新到下一发行版?
When I execute mvn release:prepare it verify that parent POM has a SNAPSHOT version and all dependent modules don't have a SNAPSHOT version. How automatically update all child modules from SNAPSHOT to the next release version?
我想为所有模块自动增加版本.
I would like automatically increment version for all modules.
推荐答案
该发布插件可以处理该问题.您是否检查过更新POM版本?但...
我什么都没有. 将POM中的版本从x-SNAPSHOT更改为新版本,并将POM中的版本更改为新值y-SNAPSHOT ,应由release:prepare
完成,例如准备发行版中进行了解释.使用此目标时出了什么问题?
The release plugin can handle that. Did you check Updating POM Versions? But...
I don't get something. Changing the version in the POMs from x-SNAPSHOT to a new version and bumping the version in the POMs to a new value y-SNAPSHOT should be done by release:prepare
as explained in Prepare a Release. What is going wrong when using this goal?
更新: autoVersionSubmodules
参数可能正是您想要的.在准备发行版的示例中:>
Update: The autoVersionSubmodules
parameter might be what you're looking for. From the Prepare a Release example:
多模块项目
系统将提示您输入版本 项目每个模块的编号. 如果您希望每个模块都能 与父POM相同的版本, 您可以设置选项
autoVersionSubmodules
至true
.轮到你了 只会被要求一次 发布版本和下一个 开发版本.
Multi-module projects
You will be prompted for the version number for each module of the project. If you prefer that every module gets the same version as the parent POM, you can set the option
autoVersionSubmodules
totrue
. Now you will be asked only once for the release version and the next development version.
父pom.xml的片段
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>x.y.z</version>
<configuration>
<goals>deploy</goals>
<autoversionsubmodules>true</autoversionsubmodules>
</configuration>
</plugin>
</plugins>
</build>
这篇关于在Maven项目中,如何自动更新所有子模块以及父模块的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!