I have a multi-module project.
parent POM (1.0-SNAPSHOT) |-- module1 (1.0-SNAPSHOT) |-- module2 (1.0-SNAPSHOT) `-- module3 (1.0-SNAPSHOT)
When I execute mvn release:prepare it verify that parent POM has a SNAPSHOT version and all dependent modules don't have a SNAPSHOT version. How automatically update all child modules from SNAPSHOT to the next release version?
I would like automatically increment version for all modules.
Backward Compatibility − You can easily port the multiple modules of a project into Maven 3 from older versions of Maven. It can support the older versions also. Automatic parent versioning − No need to specify the parent in the sub module for maintenance.
A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.
Yes you can use Maven Profiles to manage this. Obviously you can tweak this approach to suit your needs however works best.
A flexible way to set poms versions, multi-modules projects included, is Versions Maven Plugin.
mvn versions:set -DnewVersion=your_new_version
It will adjust all pom versions, parent versions and children versions in a multi-module project.
then
mvn versions:commit
or
mvn versions:revert
The release plugin can handle that. Did you check Updating POM Versions? But... I don't get something. Changing the version in the POMs from x-SNAPSHOT to a new version and bumping the version in the POMs to a new value y-SNAPSHOT should be done by release:prepare
as explained in Prepare a Release. What is going wrong when using this goal?
Update: The autoVersionSubmodules
parameter might be what you're looking for. From the Prepare a Release example:
Multi-module projects
You will be prompted for the version number for each module of the project. If you prefer that every module gets the same version as the parent POM, you can set the option
autoVersionSubmodules
totrue
. Now you will be asked only once for the release version and the next development version.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>x.y.z</version> <configuration> <goals>deploy</goals> <autoversionsubmodules>true</autoversionsubmodules> </configuration> </plugin> </plugins> </build>
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