Reputation: 45
My pom contains a version number following a sequence similar to 2.0-SNAPSHOT, at the same time we build the project with a manifest file, that needs parts of that version number since other projects are dependent on the specific version, however to simplify parts of the development we use 2.0 as the implementation version, so we dont have to switch between 2.0-SNAPSHOT and 2.0 in our dependency setup i would like to know if its possible to exclude the -SNAPSHOT from the ${project.version} so we dont have to maintain a variable manually?
Upvotes: 0
Views: 1049
Reputation: 97547
For such purposes the build-helper-maven-plugin is the right one like this:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
It will provide the following properties:
parsedVersion.majorVersion
parsedVersion.minorVersion
parsedVersion.incrementalVersion
parsedVersion.qualifier
parsedVersion.buildNumber
Apart from that it sounds strange that you need the 2.0 as a released version where you don't have released the artifact yet. So you should think about using the maven-release-plugin to release artifacts which will change the version for your current project a like.
Upvotes: 1