使用Maven2过滤添加当前日期 [英] Adding the current date with Maven2 filtering
本文介绍了使用Maven2过滤添加当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Maven2项目,我需要在属性文件中添加当前版本和当前日期.
I have a Maven2 project, and I need to add, in a properties file, the current version and the current date.
对于当前版本,我使用了${project.version}
,它可以正常工作.
For the current version, I've used ${project.version}
, which works correctly.
我的问题是如何在属性文件中设置当前日期(即Maven2完成构建的日期):
My question is how can I set the current date (i.e. the date when the build is done by Maven2) in my properties file:
client.version=Version ${project.version}
client.build=???
(此外,如果我可以指定日期的格式,那将非常棒)
(in addition, if I can specify the format for the date, it will be really great)
推荐答案
您可以使用 Maven内部版本号插件:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
</configuration>
</plugin>
</plugins>
</build>
日期然后在属性$ {buildNumber}中可用.
The date is then available in the property ${buildNumber}.
这篇关于使用Maven2过滤添加当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文