title: Maven branch update projects version automating release workflow
body: <p>I have a difficult case to solve regarding the Maven automated projects versioning, I hope I'll find a proper solution based on your experience and advices.</p>
  
  <p>The problem is like that:
       We have a huge mavenized java product which comprise of ~200 very interdependent different projects. 
       We agreed that each project should be developed independently, so that each of them should have it's own lifecycle. 
       It's all working fine in the development stage, there is no problem. The problem comes when we are preparing the release for these projects: Because the are so many projects the manual changes are a pain so we decided to find an automated solution to solve the release process. </p>
  
  <p>The prequisites are these:
  We all agreed that the release policy from SVN perspective should be like that:
  - all development should be performed on SVN trunk, releases should be created and maintained on branches. Each performed release should automatically create a tag.</p>
  
  <p>The policy from MAVEN perspective is like that:
  - before releasing a project, we first copy the trunk to a branch in order to have control over projects maintainance on the branched code. The versioning system we choose is: <strong>Major.Minor.BuildNumber-SNAPSHOT (e.g. 1.0.0-SNAPSHOT)</strong>. When branching the code, we want to change the project version number by incrementing the <strong>MinorVersion (e.g trunk-1.0.0-SNAPSHOT</strong> will become <strong>1.1.0-SNAPSHOT, and 1.0.0-SNAPSHOT will be copied and released on the new created branch)</strong>
  - when we decide that the project is mature enough in order to be released we are releasing it by using <em>maven-release-plugin</em> (<strong>mvn release:clean release:prepare release:perform</strong>) so that our project version will be transformed from <strong>Major.Minor.BuildVersion-SNAPSHOT (e.g. 1.0.0-SNAPSHOT)</strong> to <strong>Major.Minor.BuildVersion (e.g. 1.0.0)</strong>, then will be prepared for the next development iteration like: <strong>Major.Minor.BuildVersion+1-SNAPSHOT (e.g. 1.0.1-SNAPSHOT)</strong></p>
  
  <p>The problems we are facing are related to projects versioning. 
  So, during the development phase on the trunk, all the projects are using the latest SNAPSHOT versions of their dependencies (<strong>mvn versions:use-latest-versions -DallowSnapshots=true -DupdateDependencies=true</strong>), but when we consider it's time to start the release procedure and prepare to branch the code, there problems start:
  we are start branching </p>
  
  <ol>
  <li><p>parent-pom </p>
  
  <p>(<strong>mvn -B release:clean release:branch -DbranchName=${project.artifactId}_${project.version} -Dusername=${username} -Dpassword=${passwd} -Dproject.rel.${groupId}:${projectId}=1.0.0-SNAPSHOT
  -Dproject.dev.${groupId}:${projectId}=1.1.0-SNAPSHOT</strong>) </p>
  
  <ul>
  <li>copy project from trunk to new created branch, transform pom version on trunk from 1.0.0-SNAPSHOT to 1.1.0-SNAPSHOT</li>
  </ul></li>
  <li><p>non-dependent projects </p>
  
  <p>(<strong>mvn -B release:clean release:branch -DbranchName=${project.artifactId}_${project.version} -Dusername=${username} -Dpassword=${passwd} -Dproject.rel.${groupId}:${projectId}=1.0.0-SNAPSHOT
  -Dproject.dev.${groupId}:${projectId}=1.1.0-SNAPSHOT versions:update-parent 
      -DallowSnapshots=true</strong>)</p>
  
  <ul>
  <li>copy project from trunk to new created branch, </li>
  <li>transform the trunk pom version 1.0.0-SNAPSHOT become 1.0.1-SNAPSHOT</li>
  <li>update parent-pom.version: 1.0.0-SNAPSHOT become 1.1.0-SNAPSHOT</li>
  </ul></li>
  <li><p>dependent projects: </p>
  
  <p>(<strong>mvn -B release:clean release:branch -DbranchName=${project.artifactId}_${project.version} -Dusername=${username} -Dpassword=${passwd} -Dproject.rel.${groupId}:${projectId}=1.0.0-SNAPSHOT
  -Dproject.dev.${groupId}:${projectId}=1.1.0-SNAPSHOT versions:update-parent 
      -DallowSnapshots=true versions:use-latest-versions -DallowSnapshots=true 
      -DupdateDependencies=true</strong>)</p>
  
  <ul>
  <li>copy project from trunk to new created branch </li>
  <li>transform pom version on trunk from 1.0.0-SNAPSHOT to 1.1.0-SNAPSHOT</li>
  <li>update parent-pom on trunk from 1.0.0-SNAPSHOT to 1.1.0-SNAPSHOT</li>
  <li>update the already branched dependency projects from 1.0.0-SNAPSHOT to 1.1.0-SNAPSHOT</li>
  </ul></li>
  </ol>
  
  <p>The first problem here is that there is no way yet to have an argument to increase the MinorVersion when branch the project, the maven-release-plugin 2.2.2 does not increment the pom MinorVersion on trunk when branching, so that's why we need to use <strong>-Dproject.rel.${groupId}:${projectId}=1.0.0-SNAPSHOT
  -Dproject.dev.${groupId}:${projectId}=1.1.0-SNAPSHOT</strong> arguments and change them manually for every project, so 200 times every time when we preapare for a new release.</p>
  
  <p>I'm wondering if it's not a way to make all described procedure somehow in an automated fashion and to not need to perform all these changes manually all the time.
  We've taking account even to modularize this product so that to colapse those 200 project in 100 probably, but this is not acceptable since the idea is to have a fine grained projects versioning and have all the projects with it's own lifecycle, so an aggregator (I mean a classic one) is out of discussion here.</p>
  
  <p>We are using SVN as VCS, Maven as build tool (probably you already figured out about that :) ), and Bamboo as a CI server (actually, instead of "Maven Dependency Processor" feature, Bamboo is not helping me to much regarding the versioning problem).</p>
  
  <p>Do you guys have any idea in order to find a proper solution for this problem, maybe another plugin which would help (versions-maven-plugin does not change versions automatically when branch), maybe another point of view for this, I don't know..., any help or sugestion are welcome.</p>
  
  <p>Thanks!</p>