Issue
I am working on a multi-module project. For the purposes of this exercise we can assume there are two sub-modules. The articles Maven Simple Project Archetype and href="https://maven.apache.org/archetype/maven-archetype-plugin/examples/create-multi-module-project.html" rel="nofollow noreferrer">Create an archetype from a multi-module project can be referenced to follow along.
Parent - 1.0.0-SNAPSHOT
ChildA - 1.2.3-SNAPSHOT
ChildB - 1.0.0-SNAPSHOT
When I run mvn versions:set -D removeSnapshot -D processAllModules
I expect the versions to change as indicated below.
Parent - 1.0.0
ChildA - 1.2.3
ChildB - 1.0.0
But, it seems -SNAPSHOT is stripped from all versions except the children that have a different version from the parent.
Parent - 1.0.0
ChildA - 1.2.3-SNAPSHOT
ChildB - 1.0.0
Is there any way to run the mvn versions:set
command to honor the version number, while stripping the -SNAPSHOT
postfix?
UPDATE #1
Running mvn versions:set -D removeSnapshot=true
yields the same results as running mvn versions:set -D removeSnapshot -D processAllModules
.
Parent - 1.0.0
ChildA - 1.2.3-SNAPSHOT
ChildB - 1.0.0
Solution
As per the Maven Enforcer documentation for multi-module projects...
The best practice in Maven is that all childs inherit the version from their parent and don't define a new version which looks like this:
<parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module1</artifactId>
(..)
Additional use cases can be found in the linked article above.
Answered By - Mike Deitrick
Answer Checked By - Gilberto Lyons (JavaFixing Admin)