Generating branches with Git and renaming the maven version

image
Rodrigo Asensio 9 years ago

1 min read

Challenges around git and maven renaming


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..

#!/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

image

Rodrigo Asensio

Rodrigo Asensio is Manager of Solution Architecture at Amazon Web Services. He has more than 20 years of experience designing and operating distributed solutions. He is currently responsible for a team in the Enterprise segment helping large clients accelerate their adoption of the cloud and optimize the utilization of their resources.

Check out all articles