Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven versioning in GitFlow

Tags:

Git Flow has been around for a long time and lots of people seem to be adopting it for as their favourite git workflow.

When it comes down to implementing Git Flow in a Java / Maven setting, I was wondering how one should approach versioning the software modules that live on all the branches below.

enter image description here

In a simplistic Maven world,

  • developers always work on SNAPSHOT versions (ex: 0.0.1-SNAPSHOT)
  • some release process create a release (0.0.1)
  • A new snapshot version is made available for developers to develop on (0.0.2-SNAPSHOT).

If all you had was a Develop and Master branch this would be ok, but how do you handle maven versioning in GitFlow.

The versions on the master are pretty easy to define, as they will be the versions that are ultimately created and released from the Release branch.

But as soon as code goes to a release branch, what versioning strategy do you deploy here ?

  • I guess we need to reserve a new version number on the release branch to avoid conflicts with Develop ? And how will that version number relate to whatever is on the develop branch.
  • I assume that on the release branch there can also be multiple commits before the release goes into production. As we cannot re-use non-snapshot versions, do we increment fixed versions here with each commit, or also work with release-snapshot versions before finalising and pushing to master ?
  • When we merge changes back from the release to the develop branch do we start a new snapshot version ?
like image 454
ddewaele Avatar asked Nov 18 '17 16:11

ddewaele


1 Answers

For release branch we should following 0.0.1-RC-SNAPSHOT naming convention. Also please explore the mvn jgitlfow plugin. Which will provide all the above discussed features .

Please include the following depedency.

   <plugin>
                <groupId>external.atlassian.jgitflow</groupId>
                <artifactId>jgitflow-maven-plugin</artifactId>
                <version>${jgitflow-maven-plugin.version}</version>
                <configuration>
                    <enableSshAgent>true</enableSshAgent>
                    <noDeploy>true</noDeploy>
                    <noReleaseBuild>true</noReleaseBuild>
                    <noFeatureBuild>true</noFeatureBuild>
                    <noHotfixBuild>true</noHotfixBuild>
                    <enableFeatureVersions>true</enableFeatureVersions>
                    <releaseBranchVersionSuffix>RC</releaseBranchVersionSuffix>
                    <allowSnapshots>true</allowSnapshots>
                    <pushReleases>true</pushReleases>
                    <pushHotfixes>true</pushHotfixes>
                    <pushFeatures>true</pushFeatures>
                    <flowInitContext>
                        <versionTagPrefix>v</versionTagPrefix>
                    </flowInitContext>
                </configuration>
            </plugin>

Example cammands

mvn jgitflow:release-start

creates a release branch with RC and updates develop branch pom to next version

 mvn jgitflow:release-finish

Mergers relaese to master and develop and creates a tag : Mostly this branch goes Integration testing any bug fix are commited to the release branch, when it is closed develop also get the updates as it is merged.

creates a release branch with also updates the develop pom ie before (devlop 0.1-SNAPSHOT) After devlop 0.2-SNAPSHOT and a release branch of 0.1-RC-SNAPSHOT is create

https://bitbucket.org/atlassian/jgit-flow/wiki/Home

like image 99
loneStar Avatar answered Sep 24 '22 18:09

loneStar