Search code examples
mavenjenkinsmaven-release-plugin

Updating Versions using maven-release-plugin


I am using maven 3.0.4 in combination with cvs and jenkins.

I have a multi-module project with a main pom and some modules.

For a correct versioning i set some environment variables in jenkins.

The first step is that i have a pre-build-step in jenkins that executes an maven goal:

--batch-mode release:update-versions -DdevelopmentVersion=${ACTUAL_VERSION}${BUILD_NUMBER}-SNAPSHOT

Now maven is updating the Version of my parent pom and the connection from the modules to the parent pom. this is all working fine, but i have some internal dependencies between the modules which are not updated. how can i force maven to update them too?

Example:

--Parent -- Module1 -- Module2

In module 2 there is an dependency to module1, e.g.

<dependency>
    <groupId>xyz</groupId>
    <artifactId>module2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

After the release:update-versions the parent pom and the modules are updated but the dependency now still refers to the old version. is there any way to update this dependency version?


Solution

  • The simplest and best solution (in my opinion) is to use :

    <dependency>
        <groupId>xyz</groupId>
        <artifactId>module2</artifactId>
        <version>${project.version}</version>
    </dependency>
    

    instead of hard coded version. May be you can use the following as well:

    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>module2</artifactId>
        <version>${project.version}</version>
    </dependency>