For such thing there is a solution in Maven 3.5.0 you can use ${sha1}
, ${changelist}
, ${revision}
for such purposes. Either a single one of them or you can combine them together.
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>18</version>
</parent>
<groupId>org.apache.maven.ci</groupId>
<artifactId>ci-parent</artifactId>
<name>First CI Friendly</name>
<version>${revision}${sha1}${changelist}</version>
...
<properties>
<revision>1.3.1</revision>
<changelist>-SNAPSHOT</changelist>
<sha1/>
</properties>
</project>
By using the above you can simply build the application using:
mvn clean package
But also it's possible to do it like this:
mvn -Drevision=2.7.1 clean package
Based on your example you can use:
mvn -Dsha1=-XXXX clean package
where the XXXX
can be replaced with information extracted from Git (describe) or even better with informations from Jenkins (GIT_REVISION etc.).
Very important hint use the flatten-maven-plugin as described in the in the ci friendly documentation page.