M1 Tip#11: Customize project's version for nightbuilds

It might be useful to customize a project's current version in certain circumstances. For instance, a continuous integration tool can build a NIGHTBUILD-SNAPSHOT of your project. While the deploy-snapshot achieves this goal, it does not allow external teams to depend on the project, especially if multiple versions are used. In this case, you might have different instances with 1.3-NIGHTBUILD-SNAPSHOT, 2.0-NIGHTBUILD-SNAPSHOT, etc.

This is very useful if you want your project to be continuously integrated with other teams. To modify the current version of your project in a given goal, one would write the following:

<goal name="ci:run"> 
  <j:set var="currentVersion">NIGHTBUILD-SNAPSHOT</j:set> 
  ${pom.setCurrentVersion(currentVersion)}

<attainGoal name="clean:clean"/> <attainGoal name="jar:deploy"/> <attainGoal name="site:deploy"/> </goal>

Note that if you use the {pom.currentVersion} within your project, it won't be updated since the pom is loaded when maven starts.