What is the best practice for versioning and release management in the following case with multiprojects?
I want to set only one time the version for the parent and all child projects, because every part of the project must have the same version.
Also what i want is, to release the project with continuum/maven.
Normaly a easy way should be to set the version in the parent pom and say in every child „last version from parent“ but this dont work with maven <3.1 (See here)[http://jira.codehaus.org/browse/MNG-624] Now i set in every child project the version of the parent project and for every release i must change the version in all childs and the parent.
Example:
Parent
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
Child
<parent>
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.test</groupId>
<artifactId>com.test.project</artifactId>
<version>${parent.version}</version>
If i want to release my projects now with Continuum i use the following order to release it:
But this dont work, because after changeing the version of the parent, the childs dont have anymore a SNAPSHOT version in the parent and i think there must be a better way to release a multiproject with continuum.
If the first release is a stable one - it should be 1.0. 0. ###. In the more likely case the first release is not a stable one - it should be 0.1.
The first digit representing major milestones. The second digit represents incrementing the release (I generally release once a week so I increment the second digit). The third digit is used for patches, so if there is a bug in the code that is fixed outside of the normal release schedule I use the third digit.
If you add your child modules in the <dependencyManagement/>
tag I am quite sure that you will not have that problem.
Parent
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>com.test.child1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.test</groupId>
<artifactId>com.test.child2</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Child1
<parent>
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<!-- groupId and version can be skipped since it will be inherited from parent -->
<artifactId>com.test.child1</artifactId>
Child2 (depends on Child1)
<parent>
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<!-- groupId and version can be skipped since it will be inherited from parent -->
<artifactId>com.test.child2</artifactId>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>com.test.child1</artifactId>
</dependency>
</dependencies>
If you try to when using the dependencyManagement the dependencies between modules will never have to define any versions since they are defined in the parents pom.
I have never had any problems with releasing multi-module projects by this approach.
Edit
To be clear: dependencyManagement
does not have anything to do with the inheritence between parent-child. It solves any problems with the version of dependencies between child modules. And it works during releases.
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