使用 jgitver 在 Maven 版本中提交时间戳

Commit timestamp in Maven version using jgitver

我正在评估用于根据 git 元数据计算人工制品版本的 jgitver Maven 扩展。

jgitver 在名为 jgitver.head_commit_datetimeproperty 中提供提交日期时间,但我不知道如何在版本字符串中包含时间戳。

有人可以帮忙吗?

感谢 maven 惰性评估,您可以使用版本插件将它们提供到构建中,例如:

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

试试看,然后告诉我。

它基本上将 属性 传递给 versions:set 插件,这会将所有 pom 文件重写为给定的新版本。

@otto.poellath,可以使用配置属性 useGitCommitTimestamp,设置为true;它仅在 jgitver 的 non maven 模式下可用,因为它与严格的 maven SNAPSHOTs 有点冲突。

因此,如果您的 .mvn/jgitver.config.xml 配置文件包含如下内容,它将起作用:

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

这里是本地 mvn validate 在 jgitver-maven-plugin 上使用这样的配置

的输出
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] ------------------------------------------------------------------------
...