Home Ask Login Register

Developers Planet

Your answer is one click away!

kjetil February 2016

Maven release plugin - resolving RELEASE version of parent when tagging

I release projects using maven release plugin. Version of parent-pom is set to 'RELEASE'.

Like this:

<artifactId>My Application</artifactId>

Are there any ways to get the release-plugin to tag project in git with actual parent-pom version, while still keeping RELEASE in master/branch?

I would like pom.xml in tag (only) to look like this:

<artifactId>My Application</artifactId>

In most cases I need to use latest RELEASE of parent. E.g. To make sure CI server build and test all children upon new parent release. However, if i later need to go back to a previous tag I will have to manually figure out which version of the parent pom was used at the time it was first tagged.

The only way I can think of doing this is to use 'versions plugin' to resolve parent before releasing, then make sure to revert to 'RELEASE' afterwards. To me this sounds like a messy option as developers are going to forget it all the time, not to mention the extra hassle and git-pushing with each and every release.


gogstad February 2016

If your version-tag contains the string "RELEASE" when the pom is loaded to memory by maven; that is, that's the string $project.version resolves to, then that's the version available to all plugins and you will not be able to change it.

I assume you're using CI to do the actual release. If you're using Jenkins and the M2 Release plugin, then you have some environment variables at you disposition that might help you: $MVN_RELEASE_VERSIONand $IS_M2RELEASEBUILD. You for instance use those as input to the maven scm plugin and do a manual tag.

That said, if your <version>-tag doesn't contain the version of the POM, you're pretty much on your own. You should consider conforming the standard way of using maven, and find some other solution to whatever problem caused you to put that string there in the first place.

A final note on the subject of releasing in maven and git: Atlassian has develop a release plugin that is much more versatile than the original maven release plugin, link. It is tailored for the "git flow" branching model.

Post Status

Asked in February 2016
Viewed 2,332 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life