While development we use the SNAPSHOT version (for example 1.0-SNAPSHOT) for maven modules.
For example Parent Module's Maven Configugration:
<groupId>com.mycomp.basemodule</groupId>
<artifactId>base-module</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>base-module</name>
<modules>
<module>sub-module1</module>
<module>sub-module2</module>
<module>sub-module3</module>
<module>sub-module4</module>
</modules>
For example Child Module's Maven Configugration:
Sub-Module-1:
<parent>
<groupId>com.mycomp.basemodule</groupId>
<artifactId>base-module</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.mycomp.sub-module1</groupId>
<artifactId>sub-module1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>sub-module1</name>
Also consider same configuration for other sub modules (2,3,4) too.
While releasing the project/patch, we need to change this SNAPSHOT version to actual release version.
There is one crude way to change the version. I can go to each and every pom.xml for parent and all child modules and can change the SNAPSHOT version to release version.
Is there any other best practice to change this SNAPSHOT version to release version at common place so that I don't need to update all pom.xml files?
I believe, you should use maven-release plugin
to solve the problem in the way it has been intended in maven. See: http://maven.apache.org/guides/mini/guide-releasing.html
As docs say:
The main aim of the maven-release plugin is to provide a standard mechanism to release project artifacts outside the immediate development team. The plugin provides basic functionality to create a release and to update the project's SCM accordingly.
UPDATE: seems you're not the first one having the question, see: Maven versioning best practices Answer seem to be quite complete there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With