Reputation: 113
I have third party Java
project which uses Maven
to build.
The project has specified 1.0-SNAPSHOT
as version in pom.xml
file.
...
<version>1.0-SNAPSHOT</version>
...
I'd like to build project on private build server and install resulting jar
into private maven repository.
Currently when project is installed or deployed via mvn install
or mvn deploy
the resulting artifact has suffixed with timestamp like this artifact-name-1.0-20200320.102713-1.jar
.
Such version is rather uninformative.
I'd like to have version suffix to include git describe
instead of timestamp.
Is there a way to customize suffix to include more information like git commit id?
Upvotes: 1
Views: 609
Reputation: 35805
The situation is a bit different to what you probably think.
Maven has just one build in mechanism that does not treat a version number "verbatim", and this mechanism is SNAPSHOT
. SNAPSHOT
versions are stored in Nexus/Artifactory as time-stamped, numbered versions so that Nexus/Artifactory can always give you last version when you ask for SNAPSHOT
. There is no way to alter that mechanism.
On the other hand, you can build non-Snapshot versions that depend on properties.
You can e.g. define a version 1.0.0-${revision}
and set the property revision
through the command line.
Upvotes: 1