MiamiBeach
MiamiBeach

Reputation: 3487

Releasing the project with Maven: different release versions of artifacts

I have a maven project with multiple modules. When I release it I just change the versions of the modules from SNAPSHOT to release's version and its ok. This can be done with Maven Release Plugin.

The problem arises because some of the dependencies I have are actually the artifacts, developed by other groups of our programmers. Thus their versions may often change, which is a behaviour opposite to other dependencies, for example hibernate's artifact versions. At the moment of release I would like to use some available versions of that rapidly changing libraries. Probably the last one. May be they will release a new version of their library specially for my release. Note that their library is a separate Maven project with separate version controlled by them.

All I can do now is just to check manually which version of the that dependency is the last and put it down manually into my POM. Its not that convenient. May be there is a better way to organize it with Maven and TeamCity? Can I update the versions of that other group's artifacts too? Their version should be derived from their Snapshot version, or from the last release they have deployed into the Nexus.

Upvotes: 0

Views: 1642

Answers (2)

OhadR
OhadR

Reputation: 8839

As mentioned, you can use Versions Maven Plugin, and more specifically you need versions:update-properties. As you can read the manual, it

Sets properties to the latest versions of specific artifacts.

The condition is that you work with repository manager (e.g. Artifactory). Maven knows to search this repo for the most updated aritfacts.

Before you run the maven-release-plugin, you run the versions-plugin that updates your dependencies. For example, you run versions:update-properties with the relevant parameters.

If you would like to print latest versions of artifacts, the same versions-plugin is your friend. Have a look and read the link I've sent you above; the relevant command is versions:display-dependency-updates.

If you would like to print selectively, only your artifacts latest versions, you can set their version using a property. for example, if you have dependency JAR X, write in the main pom something like this:

<dependency>
   <groupId>myGroup</groupId>
   <artifactId>X</artifactId>
   <version>${x.version}</version>
</dependency>

<properties>
   <x.version>3.1.0.RELEASE</x.version>
</properties>

Then you use versions:display-property-updates -DincludeProperties="x.version"

Upvotes: 0

Eugene Kuleshov
Eugene Kuleshov

Reputation: 31795

You can use versions-maven-plugin to automate updating external dependencies.

Upvotes: 1

Related Questions