Performing property calculations

Is it possible to perform string and mathematical operations on properties in maven 2?

I have a ${version} property that has a value of something like 5.3.0-SNAPSHOT , now I would like to extract 5 and do some math on it, for example, subtract 3 from This. Thus, my new property will get a value of 2.

+7
source share
2 answers

You can watch the parse-version goal of building a maven helper plugin . As an example, this page indicates that after launching this goal, it provides a bunch of propositions that can be used for subsequent operations.

 parsedVersion.majorVersion parsedVersion.minorVersion parsedVersion.incrementalVersion parsedVersion.qualifier parsedVersion.buildNumber 
+5
source

Here is an example ( http://ronalleva.com/groovy/maven/programming/2008/01/23/using-the-groovy-maven-plugin-to-do-magic.html ) that inserts groovy into your plugin. In the following example, he sets the property in the maven project.

+2
source

All Articles