Maven: Best way to change SNAPSHOT to release version for parent / child modules at release time?

During development, we use a version of SNAPSHOT (e.g. 1.0-SNAPSHOT) for maven modules.

For example, the parent Maven Configugration module:

<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, the Maven Configugration child module:

submodule-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 the same configuration for other auxiliary modules (2,3,4).

When a project / patch is released, we need to change this version of SNAPSHOT to the actual version.

There is one rough way to change the version. I can go to each pom.xml for the parent and all child modules and change the version of SNAPSHOT to release the version.

Is there any other best practice for changing this version of SNAPSHOT to release the version in a common place, so that I do not need to update all the pom.xml files?

+8
maven-3
source share
2 answers

I believe you should use the maven-release plugin to solve the problem of how it was intended for maven. See: http://maven.apache.org/guides/mini/guide-releasing.html

As the docs say:

The main goal of the maven-release plugin is to provide a standard mechanism for releasing project artifacts outside the immediate development team. The plugin provides basic functions for creating a release and updating an SCM project.

UPDATE: it seems you are not the first to have a question, see: best examples of using versions of Maven The answer seems pretty complete.

+7
source share

A simpler way: update the version using maven-version-plugin , then prepare the release in your own way.

+3
source share

All Articles