2

I have the feeling I'm doing something wrong here as I have been digging around the net for a while (stackoverflow included of course) and yet that rendered no results!

In brief, I have a maven project set up with maven release plugin which works fine, increments the version correctly, checks in code in SVN, tags and deploys with no problem.

However, the need has arrived to also generate a script with each release which has to reference the jar generated. This means 2 things:

  1. for the release version, change the script to contain the release version, commit it back in SVN (so it gets tagged etc)
  2. following the release, the script has to be updated to contain the (next) SNAPSHOT version and committed back into SVN

For example, let's assume my current working version of the pom is 1.1.1-SNAPSHOT. As such my script.sh contains a reference to project-1.1.1-SNAPSHOT.jar. When I perform a mvn release:prepare (assuming I will stick with the versions suggested by maven-release-plugin) the release version will become 1.1.1. At this stage, my script.sh should be changed to reference project-1.1.1.jar and committed back in. Upon mvn release:perform all the 1.1.1 the tagging occurs, deployment to maven repo etc. And following that, my pom will be changed to 1.1.2-SNAPSHOT and committed back in SVN. At this point my script needs to be changed to reference project-1.1.2-SNAPSHOT.jar.

I figured out I can alter the script easily by using something like GMaven plugin -- and I have got the script in fact to kick in during prepare-resources phase (though maybe I need to look at another one?) however the biggest problem I see is retrieving the versions that maven-release-plugin has decided to use: in other words, how do I find out:

  • release version that maven-release-plugin has decided to use
  • next dev/SNAPSHOT version that maven-release-plugin will use

Once I get access to these I think I can get GMaven to execute the required code to change my script accordingly. (Though, if looking at the above scenario you can recommend a better way of doing this I would be more than glad to hear it!) Are there any properties like ${project.releaseVersion} (that doesn't work by the way) which could give me these 2 version numbers?

Thanks in advance!

Liv

Liv
  • 6,006
  • 1
  • 22
  • 29
  • There might be another approach to this: there is ${project.version} which I can use in gmaven, however, to use the correct (release) one I need to run my code AFTER the release plugin updated the release numbers but BEFORE it does an SVN commit -- would that make things easier? – Liv Feb 15 '12 at 01:49
  • If a script is in the same directory ( or in the same relative path to ) pom.xml, why not to get the version number from pom directly? – Alexander Pogrebnyak Feb 15 '12 at 01:54
  • It is a script inside the project (so a subdirectory); getting the version from the pom is possible as per my comment, that does mean though that it becomes crucial WHEN gmaven code gets executed. In process-resources phase, the releave version will be (in my above example) 1.1.1-SNAPSHOT -- whereas I need the release version (1.1.1). – Liv Feb 15 '12 at 02:07
  • I also need this. Since the ${project.version} has the name with -SNAPSHOT appended to it I guess I could strip off the -SNAPSHOT using the build-helper-maven-plugin, Seems like a lot of work. – ggb667 Jun 03 '14 at 18:08

0 Answers0