开发者

Create a branch from a tag with maven

开发者 https://www.devze.com 2023-01-18 09:24 出处:网络
I develop in trunk and periodically tag \"s开发者_如何学Pythontable releases\" with the maven release plugin. For example:

I develop in trunk and periodically tag "s开发者_如何学Pythontable releases" with the maven release plugin. For example:

/trunk is MyProject 1.1-SNAPSHOT

creates the stable release

/tags/MyProject-1.1

Works fine, no problems, just perfect.

Sometimes I have to deploy a hotfix but the trunk isn't ready, yet. So I need a branch from the last stable tag. Can maven help me here? Currently I copy the tag to the new branch location /branches/MyProject-1.1.1-SNAPSHOT and update the versions with mvn versions:set


So I need a branch from the last stable tag. Can maven help me here?

The Maven Release Plugin and its release:branch can help. Check out the tag and create a branch from the tag:

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.

Resources

  • Maven Release Plugin Examples
    • Create a Branch


If you have a standard project in svn with trunk/tags/branches structure:

MyProject
   \trunk
   \branches
       \theOldBranch
   \tags
       \MyProject-1.1
       \MyProject-1.2
       \MyProject-1.3

You should

mvn release:branch -DbranchName=theNewBranchFrom12 -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false -Dtag=MyProject-1.2

After that you should see MyProject\branches\theNewBranchFrom12 with pom files modified according to what you suggested when release:branch was executed.

0

精彩评论

暂无评论...
验证码 换一张
取 消