Since Maven 3.5.0 this is possible using a special predefined property: ${revision}
. Define the property with a default value (e.g. 1.5.0-SNAPSHOT
) and when needed, set it during execution to a specific version (e.g. 1.5.46
).
For example, define the following in your pom.xml
:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>foo</artifactId>
<name>Foo Module</name>
<version>${revision}</version>
...
<properties>
<revision>1.5.0-SNAPSHOT</revision>
</properties>
</project>
Build it using the default value:
mvn clean install
This will produce an artifact identified as org.example:foo:1.5.0-SNAPSHOT
.
In order to build a specific version, set the revision
property, for example:
mvn clean install -Drevision=1.5.46
This will produce an artifact identified as org.example:foo:1.5.46
.
For further details, see the Maven CI Friendly Versions page.