Reputation: 187499
I have a parent POM with the following config
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.2-SNAPSHOT</version>
Each child project which inherits from this parent POM, has a config such as the following:
<parent>
<groupId>com.amadeus.jcp.ui.skinning.skinning-system</groupId>
<artifactId>parent</artifactId>
<version>1.2-SNAPSHOT</version>
</parent>
I want all these project version numbers to stay in synch. At the moment, if I change the parent version to 1.3, I then have to go change all the child project versions to 1.3. Is there any way I can avoid duplicating the version numbers in all the child projects?
I tried replacing the above with
<parent>
<groupId>com.amadeus.jcp.ui.skinning.skinning-system</groupId>
<artifactId>parent</artifactId>
</parent>
and
<parent>
<groupId>com.amadeus.jcp.ui.skinning.skinning-system</groupId>
<artifactId>parent</artifactId>
<version>${project.version}</version>
</parent>
But neither of these work. I'm using Maven version 2.1.0.
Thanks, Don
Upvotes: 4
Views: 3775
Reputation: 570295
I tried replacing the above with (...) and (...) but neither of these work. I'm using Maven version 2.1.0.
Not possible. With Maven 2.x, you must declare the parent
element in child module and the parent
element must include a hard-coded version
(you can't omit it and you can't use a property, see this previous answer and MNG-624).
However, Maven 3.1 will supports versionless parent elements (see this previous answer).
Meanwhile, some plugin can make the maintenance a bit easier like the Maven Release Plugin or the Versions Maven Plugin and its versions:set
or versions:update-child-modules
goals.
Upvotes: 3
Reputation: 97359
You shouldn't define a version... in the child module, but you have to give that in the parent definition...
+--- root
+--- pom.xml (Parent)
+--- module1
+-- pom.xml (child 1)
You should also define a relativePath in your childs as well...
<parent>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.2-SNAPSHOT</version>
<relativePath>../pom.xml</version>
</parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
If you done so you should never change the version number by hand in your parent...let the release plugin do the work it will change the version entries in all childs (parents) appropietaley...if you really need to change things sometimes use the maven-version-plugin...
Upvotes: 0