Search code examples
javagitmavencontinuous-deploymentjgitver

Commit timestamp in Maven version using jgitver


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?


Solution

  • @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] ------------------------------------------------------------------------
    ...