更新多模块 Maven 项目中模块的版本号 [英] Updating version numbers of modules in a multi-module Maven project
问题描述
我有一个多模块的 Maven 项目.我们打算将所有这些模块一起版本化.但截至目前,我最终在每个模块 pom.xml 中的硬编码版本如下
I have a multi-module maven project. We intend to version all these modules together. But as of now I am ending up hard-coding version in each of the module pom.xml as below
<parent>
<artifactId>xyz-application</artifactId>
<groupId>com.xyz</groupId>
<version>2.50.0.g</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xyz</groupId>
<artifactId>xyz-Library</artifactId>
<version>2.50.0.g</version>
并且主要的父模块具有以下配置
and the main parent module has the below configuration
<modelVersion>4.0.0</modelVersion>
<groupId>com.xyz</groupId>
<artifactId>xyz-application</artifactId>
<version>2.50.0.g</version>
<packaging>pom</packaging>
推荐答案
使用 versions:set
来自 versions-maven 插件:
mvn versions:set -DnewVersion=2.50.1-SNAPSHOT
它将调整多模块项目中的所有 pom 版本、父版本和依赖版本.
It will adjust all pom versions, parent versions and dependency versions in a multi-module project.
如果你犯了错误,做
mvn versions:revert
之后,或
mvn versions:commit
如果您对结果感到满意.
if you're happy with the results.
注意:此解决方案假定所有模块也使用聚合 pom 作为父 pom,此方案在此回答时被认为是标准的.如果不是这种情况,请参考 Garret Wilson 的回答.
Note: this solution assumes that all modules use the aggregate pom as parent pom also, a scenario that was considered standard at the time of this answer. If that is not the case, go for Garret Wilson's answer.
这篇关于更新多模块 Maven 项目中模块的版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!