I have a multi-module maven project. We intend to version all these modules together. But as of now I am ending up hard-coding version in each of the module pom.xml as below
<parent> <artifactId>xyz-application</artifactId> <groupId>com.xyz</groupId> <version>2.50.0.g</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.xyz</groupId> <artifactId>xyz-Library</artifactId> <version>2.50.0.g</version>
and the main parent module has the below configuration
<modelVersion>4.0.0</modelVersion> <groupId>com.xyz</groupId> <artifactId>xyz-application</artifactId> <version>2.50.0.g</version> <packaging>pom</packaging>
Description: Removes the initial backup of the pom, thereby accepting the changes.
Setting the Maven versionAdd an environment variable to your development system called ATLAS_MVN. Set the value of ATLAS_MVN to your Maven executable. Keep in mind this should be the Maven executable, not the Maven home. Verify the configuration by running the atlas-version command.
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.
Use versions:set
from the versions-maven plugin:
mvn versions:set -DnewVersion=2.50.1-SNAPSHOT
It will adjust all pom versions, parent versions and dependency versions in a multi-module project.
If you made a mistake, do
mvn versions:revert
afterwards, or
mvn versions:commit
if you're happy with the results.
Note: this solution assumes that all modules use the aggregate pom as parent pom also, a scenario that was considered standard at the time of this answer. If that is not the case, go for Garret Wilson's answer.
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