Automatic project version generation using maven extensions
Plugin takes care of generating maven version based on the latest commit hash so that version can become CI friendly.
-
Add a file extension.xml under .mvn folder which is on the base directory of your maven project with the below content
com.sab.maven ci-versioning-extension 1.0.0
-
Follow projection version convention as below. So that placeholder revision will be updated by plugin in the runtime
-
Single module project:
<groupId>xx.xxx</groupId> <artifactId>xx</artifactId> <version>${revision}</version> <prerequisites> <maven>3.3.1</maven> </prerequisites> <properties> <revision>SNAPSHOT</revision> <properties>
-
Multi module structure:
-
Parent POM
xx.xxx xx ${revision}
3.3.1 SNAPSHOT -
Child POM
xx.xxx xx ${revision} 4.0.0 child.xx.xx
-
-
-
We are almost done compile the project as usual.
- Version on target pom.xml is not updating i.e placeholder revision can't be updated with the dynamic version which needs to be insvestigated.