So, today I came up with an issue when branching and renaming the maven version in a @mapaprop update. Maven release plugin really sucks when it is connected to Git. It does everything in the mainline. If your mainline (master) is your production release branch this then maven:release is really useless, so I came up with this shell script that basically does..

  • Assuming you are in the master branch
  • Enter the next %version% which will be a -SNAPSHOT
  • Creates and checkout a git branch named %VERSION%-SNAPSHOT
  • Pushes the git branch
  • Uses mojo version plugin for renaming the version to %VERSION%-SNAPSHOT
#!/bin/sh

echo "Starting git branching..."
echo "Enter new branch version: (ie. 1.2.3) "
read VERSION
echo "Building branch version $VERSION-SNAPSHOT"
git checkout -b MYPROJECT-$VERSION-SNAPSHOT

echo "Pushing branch $VERSION-SNAPSHOT to remote origin"
git push origin master MYPROJECT-$VERSION-SNAPSHOT

echo "Updating Maven version..."
mvn versions:set -DnewVersion=$VERSION-SNAPSHOT

Here you get the info for the Mojo plugin http://mojo.codehaus.org/versions-maven-plugin/examples/set.html