[英]Commit timestamp in Maven version using jgitver
I'm evaluating the jgitver Maven extension for calculating artefact versions from git metadata. 我正在评估jgitver Maven扩展,用于从git元数据计算伪影版本。
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. jgitver在名为jgitver.head_commit_datetime
的属性中提供了提交日期jgitver.head_commit_datetime
,但是我不知道如何在版本字符串中包括时间戳。
Can anyone help? 有人可以帮忙吗?
Thanks to maven lazy evaluation, you can provide them into the build using the versions plugin, something like: 借助maven惰性评估,您可以使用版本插件将它们提供到构建中,例如:
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. 基本上,它将属性传递给versions:set插件,这会将所有pom文件重写为给定的新版本。
@otto.poellath, you can use the configuration property useGitCommitTimestamp
and set it to true ; @ otto.poellath,可以使用配置属性useGitCommitTimestamp
并将其设置为true; it is only available in the non maven
mode of jgitver as it is a bit clashing with strict maven SNAPSHOTs. 它仅在jgitver的non maven
模式下可用,因为它与严格的Maven SNAPSHOT有点冲突。
So if you have your .mvn/jgitver.config.xml
config file that contains something like the following it will work: 因此,如果您的.mvn/jgitver.config.xml
配置文件包含以下内容,则它将起作用:
<mavenLike>false</mavenLike>
<useGitCommitTimestamp>true</useGitCommitTimestamp>
Here is an output of a local mvn validate
on jgitver-maven-plugin itself using such a configuration 这是使用这种配置在jgitver-maven-plugin本身上进行本地mvn validate
的输出
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] ------------------------------------------------------------------------
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.