Maven release plugin | Best practice | It is better to modify the version in the POM directly or modify the release.properties file

huangapple go评论91阅读模式
英文:

Maven release plugin | Best practice | It is better to modify the version in the POM directly or modify the release.properties file

问题

我对最佳实践有一个问题,希望能得到专家的建议。
我已经使用maven-release-plugin工具几年了,我有一个疑问,关于发布新版本,不知道哪种方式更好。通常我会修改 release.properties 文件,将要发布的新版本和接下来的快照版本写入,例如:

project.rel.com.blabla.generic-module\:my-module=1.1.0
project.dev.com.blabla.generic-module\:my-module=2.0.0-SNAPSHOT

在提交修改后的文件后,我会在构建服务器上执行 mvn release:prepare release:perform,然后版本1.1.0会被发布,而2.0.0-SNAPSHOT会被生成。

我的问题是,是不是更好的方式是修改项目中每个 pom.xml 文件,将要发布的版本号写入,还是我现在使用的机制是有效的。

提前感谢。

英文:

I have a question about best practices and would appreciate the advice of experts
I've been working with maven-release-plugin for several years, and I have a doubt that what is better to release a new version. Normally I modify the release.properties file with the new version to be released and the next one in snapshot, for example:

project.rel.com.blabla.generic-module\:my-module=1.1.0
project.dev.com.blabla.generic-module\:my-module=2.0.0-SNAPSHOT

After commit this file modified, i make mvn release:prepare release:perform from build server, and then, version 1.1.0 is released and 2.0.0-SNAPSHOT is generated.

My question is if it is better to modify each pom.xml of the project with the version that I want to release or the mechanism that I use is valid.

Thanks in advance

答案1

得分: 5

你不应该手动修改 release.properties 文件。

如果你只是使用 mvn release:prepare release:perform --batch-mode 命令,版本号会自动递增,例如从 1.0.0-SNAPSHOT 自动变为 1.0.0,而下一个开发版本将会是 1.0.1-SNAPSHOT

如果你想要改变用于发布的版本号,你可以通过以下方式实现:

mvn -DreleaseVersion=2.0.0 release:prepare release:perform --batch-mode

如果你想要定义发布版本和下一个开发版本,你可以通过以下方式实现:

mvn -DreleaseVersion=2.0.0 -DdevelopmentVersion=2.1.0-SNAPSHOT release:prepare release:perform --batch-mode

如果你有一个多模块构建项目,你应该配置使用 autoVersionSubmodules=true,通常这是在你的 pom 文件中定义的,而不是通过命令行手动设置。

英文:

You should not modify the release.properties manually.

If you just use mvn release:prepare release:perform --batch-mode the version is automatically incremented for example from 1.0.0-SNAPSHOT to 1.0.0 and the next development version will be 1.0.1-SNAPSHOT

If you like to change the version to be used for release you can simply do that via:

mvn -DreleaseVersion=2.0.0 release:prepare release:perform --batch-mode

If you like to define the release version and next developmentVersion you can do that via:

mvn -DreleaseVersion=2.0.0 -DdevelopmentVersion=2.1.0-SNAPSHOT release:prepare release:perform --batch-mode

If you have a multi module build you should configure to use autoVersionSubmodules=true which usually is defined in your pom and not manually from command line.

huangapple
  • 本文由 发表于 2020年8月20日 14:18:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/63499348.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定