1

I'll try to keep this question short and simple:

with the jgitver maven plugin I can easily create versions from Git tags. The ${jgitver.calculated_version} variable that I can use in my .pom file will, by default, behave like this:

  1. set Git tag "v1.0.0"
    version: 1.0.0
  2. do Git commit
    version: 1.0.1-SNAPSHOT

Is it possible to (and if so how can I) include the commit hash in the version number, like so?

  1. set Git tag "v1.0.0"
    version: 1.0.0-162ad57
  2. do Git commit
    version: 1.0.1-ff8cb8a-SNAPSHOT

The important part is that version numbers from simple (not tagged) commits also end with "SNAPSHOT".

Brixomatic
  • 381
  • 4
  • 16

1 Answers1

1

Yes it is possible.

in the .mvn/jgitver.config.xml file set the property useGitCommitId to true. You can also define the expected length of the SHA1 using gitCommitIdLength

something like:

<useGitCommitId>true</useGitCommitId>
<gitCommitIdLength>8</gitCommitIdLength>  <!-- between [8,40] -->
Matthieu BROUILLARD
  • 1,991
  • 1
  • 16
  • 25