I have a project where I have a need to break the version number down and access it's component pieces when building a manifest file. After doing some searching around I found the build-helper-maven-plugin and figured my problem was solved. I added the plugin to the master POM, it's shown below.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
<configuration>
<propertyPrefix>parsedVersion</propertyPrefix>
</configuration>
</execution>
</executions>
</plugin>
The project version at this point in time is 3.0.0-SNAPSHOT. I wanted to see all the pieces (although in the final version I may not use them all) so I added these lines to my manifest file.
<value name="majorVersion">${parsedVersion.majorVersion}</value>
<value name="minorVersion">{$parsedVersion.minorVersion}</value>
<value name="incrementalVersion">${parsedVersion.incrementalVersion}</value>
<value name="versionQualifier">${parsedVersion.qualifier}</value>
<value name="parsedBuildNumber">${parsedVersion.buildNumber}</value>
After building I get this.
<value name="majorVersion">0</value>
<value name="minorVersion">{$parsedVersion.minorVersion}</value>
<value name="incrementalVersion">0</value>
<value name="versionQualifier">3.00.0-SNAPSHOT</value>
<value name="parsedBuildNumber">0</value>
The value tag is actually an XML tag and there is a closing value tag in the manifest file, I had to remove them since they were messing up the display.
So the incremental version appears to be correct, although I'm not all that confident given that the major version isn't correct, it found no minor version, and the qualifier comes back as the entire version number, rather than just the SNAPSHOT piece i had expected. I can see where a build number of zero would be correct since we don't have what Maven considers a build number.
Any ideas on why the version number doesn't seem to be parsing? Have I implemented this plugin incorrectly?
thanks steve