我在主干中开发,并定期使用 Maven 发布插件标记“稳定版本”。例如:
/trunk 是 MyProject 1.1-SNAPSHOT
创建稳定版本
/tags/MyProject-1.1
工作正常,没有问题,非常完美。
有时我必须部署修补程序,但主干尚未准备好。所以我需要来自最后一个稳定标签的分支。 maven 可以帮我吗?目前我将标签复制到新的分支位置
/branches/MyProject-1.1.1-SNAPSHOT
并使用 mvn versions:set
最佳答案
So I need a branch from the last stable tag. Can maven help me here?
Maven 发布插件及其 release:branch
可以提供帮助。检查标签并从标签创建分支:
By default, the POM in the new branch keeps the same version as the local working copy, and the local POM is incremented to the next revision. If you want to update versions in the new branch and not in the working copy, run:
mvn release:branch -DbranchName=my-branch -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false
Note: This can be useful if you want to create a branch from a tag
Specify versions on the command line
You may want to specify the versions to use on the command line. This can be useful for example if you are running the release in non-interactive mode. The branch goal can use the same properties used by the prepare goal for specifying the versions to be used.
mvn --batch-mode release:branch -DbranchName=my-branch-1.2 -Dproject.rel.org.myCompany:projectA=1.2 \ -Dproject.dev.org.myCompany:projectA=2.0-SNAPSHOT
In this example, the POM in the new branch will be set to the version 1.2-SNAPSHOT, and the local POM will be set to the version 2.0-SNAPSHOT.
资源
- Maven 发布插件示例
关于svn - 使用 Maven 从标签创建分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3812262/