0
votes

I have a project with 1 parent and its multi modules

Parent - module 1 - module 2 - module 3

I am using jenkins to build project. Each parent and its modules should maintain independent versions.

Requirement is, when i do DEV release by jenkins, i want to increase version of module only if there is any change in SVN/GIT automatically if my build is successful.

Eg:

parent - 1.2

 - module1 - 1.3
 - module2 - 1.2
 - module3 - 1.4

If there are some changes done in module 3, which trigger jenkins build. If my jenkins build is successful only module3 build version should be incremented to 1.5 and pom.xml should be updated.

parent - 1.2 - module1 - 1.3 - module2 - 1.2 - module3 - 1.5

1
If they are independant why do you have a parent? Why not separating them into different projects and different jenkins jobs... - khmarbaise
I want to ensure all modules should use same dependencies versions..Thus making them under 1 parent... - LoVIn
For this intention it's not needed to define them as modules. You can define a parent separately... - khmarbaise
Sorry I am pretty new in maven. We would define all modules as independent maven project right? How they will share same pom? - LoVIn
If those different projects use the same as parent which is a separated project...? - khmarbaise

1 Answers

0
votes

We use the versions-maven-plugin to manage multi module maven pom.xml versions within our Jenkins pipeline. The plugin offers many options, but you would have to research specific ones that would suit your needs.

Documentation at: http://www.mojohaus.org/versions-maven-plugin/

The new version number may be computed by the plugin itself or an external windows/unix script which could compute and store the value in an environment variable which is accessible to the plugin.

I looked at your most recent comment and believe the cleaner solution is to not share the same parent project for managing external common dependencies. Instead I would recommend managing dependencies using a BOM.

Declare all your common dependency version, etc within a single pom.xml file. Then within your child modules, use:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>your.group.id</groupId>
            <artifactId>your.artifact.id</artifactId>
            <version>your.bom.version.number</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>