Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice: Versioning and releases in multiprojects

What is the best practice for versioning and release management in the following case with multiprojects?

Project structure

  • global parent
    • parent project (Version: 1.0-SNAPSHOT)
      • child project 1 (same like parent)
      • child project 2 (same like parent)
      • child project 3 (same like parent)
      • child project 4 (same like parent)

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.

Current "bad" solution:

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:

  1. Parent Project
  2. Child Project 1
  3. Child Project 2

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.

like image 640
Rene Herget Avatar asked Aug 20 '12 13:08

Rene Herget


People also ask

What should be the first release version?

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.

How do you name software releases?

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.


1 Answers

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.

like image 135
maba Avatar answered Sep 28 '22 21:09

maba