1

I'm evaluating the jgitver Maven extension for calculating artefact versions from git metadata.

jgitver provides the commit datetime in a property called jgitver.head_commit_datetime, but I can't figure out how to include the timestamp in the version string.

Can anyone help?

otto.poellath
  • 4,129
  • 6
  • 45
  • 60

2 Answers2

0

Thanks to maven lazy evaluation, you can provide them into the build using the versions plugin, something like:

mvn jgitver versions:set -DnewVersion=1.0.\${jgitver.head_commit_datetime} versions.commit

Try that and let me know.

It basically pass the property onto the versions:set plugin, and this will rewrite all pom files to the given new version.

Niels Bech Nielsen
  • 4,777
  • 1
  • 21
  • 44
  • unfortunately this solution introduce a pom change and a commit which is exactly what jgitver avoids – Matthieu BROUILLARD Jul 17 '18 at 07:58
  • Not necessarily, IMO. There is no reason to persist the new poms since they will always be generated back to the same number using the same code and the same command. I used this to hold the version to snapshot at all times and only append commit version on builds. – Niels Bech Nielsen Jul 18 '18 at 14:19
  • but if you do not store anything in the SCM then you are not able later on to reproduce the build – Matthieu BROUILLARD Jul 18 '18 at 19:01
0

@otto.poellath, you can use the configuration property useGitCommitTimestamp and set it to true ; it is only available in the non maven mode of jgitver as it is a bit clashing with strict maven SNAPSHOTs.

So if you have your .mvn/jgitver.config.xml config file that contains something like the following it will work:

<mavenLike>false</mavenLike>
<useGitCommitTimestamp>true</useGitCommitTimestamp>

Here is an output of a local mvn validate on jgitver-maven-plugin itself using such a configuration

H:\jgitver-maven-plugin>mvn validate
[INFO] using jgitver configuration file: H:\jgitver-maven-plugin\.mvn\jgitver.config.xml
[INFO] Scanning for projects...
[INFO] Using jgitver-maven-plugin [1.3.0] (sha1: ef8eec9f820d662e63a84f1210c377183e450cbd)
[INFO] jgitver-maven-plugin is about to change project(s) version(s)
[INFO]     fr.brouillard.oss::jgitver-maven-plugin::0 -> 1.3.1-20180710075533-integration
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jgitver Maven Plugin 1.3.1-20180710075533-integration
[INFO] ------------------------------------------------------------------------
...
Matthieu BROUILLARD
  • 1,991
  • 1
  • 16
  • 25