The current trunk version is 1.4.1-incubating-SNAPSHOT, and since we are about to release that upcoming version 1.4.1-incubating soon, I don’t want to pollute it with half-baked changes, while I’ll still need to develop on the trunk in parallel.
I’ll also need to be able to install both the current trunk and my experimental branch in my local Maven repository at the same time, hence I need a new temporary version for my branch. All this can be achieved using the Maven Release Plugin, in particular the branch goal. Maven Release supports 14 SCMs through the same interface; in this case we use SVN, though.
What I want
- A new branch at https://svn.apache.org/repos/asf/incubator/npanday/branches/1.5.0-azuresupport,
- and properly versioned POMs, using version 1.5.0-azuresupport-SNAPSHOT.
The command I need to run
mvn release:branch -DbranchName=1.5.0-azuresupport -DautoVersionSubmodules=true -DsuppressCommitBeforeBranch=true -DremoteTagging=false -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false
Lets go through the settings line-by-line:
Loads and executes the branch-goal from the Maven Release Plugin.
The name for the branch to be created. When on trunk, Maven figures out to use the default SVN layout for branches and tags. You can optionally define the branch base using the parameter branchBase like this: –DbranchBase=https://svn.apache.org/repos/asf/incubator/npanday/branches/
When ran, Maven will prompt for the version to be used in the branch. I provided 1.5.0-azuresupport-SNAPSHOT. Since autoVersionSubmodules is set to true, Maven Release will automatically use this versions for all submodules and hence also update all inner-project dependencies to that version.
The next four settings go hand-in-hand.
By default, Maven Releases creates intermediate commits to the current working copy. I’m not sure of the reason, but I think it was because some VCS do not support branching/tagging of modified working copies. This parameter makes sure, no intermediate commits are made to the working copy.
With SVN, by default, tags are created remotely. If you want to ommit intermediate commits, this must be set to false.
When branching, you can either define new versions for the current working copy, or the new branch, or both. As set here, the working copy will be left alone, and the plugin will ask for a new version for the branch.
Now I can switch forth and back between the trunk and the new branch, but still build and deploy artifacts side-by-side.
Defaults in POM
You may also provide the fixed values in the POM. And if you want to avoid interfering with other Maven Release actions, you might want to use a profile.
<profile> <id>branch</id> <activation> <property> <name>branchName</name> </property> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.2.1</version> <configuration> <branchBase>https://svn.apache.org/repos/asf/incubator/npanday/branches</branchBase> <autoVersionSubmodules>true</autoVersionSubmodules> <suppressCommitBeforeBranch>true</suppressCommitBeforeBranch> <remoteTagging>false</remoteTagging> <updateBranchVersions>true</updateBranchVersions> <updateWorkingCopyVersions>false</updateWorkingCopyVersions> </configuration> </plugin> </plugins> </build> </profile>
Now it will be enough, when I run mvn release:branch –DbranchName=1.5.0-azuresupport