如何访问 maven.build.timestamp 进行资源过滤 [英] How to access maven.build.timestamp for resource filtering

查看:34
本文介绍了如何访问 maven.build.timestamp 进行资源过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 maven 3.0.4 并希望我的应用程序可以访问构建时间戳.为此,我在 .properties 文件中放置了一个占位符,并让 maven 过滤构建.虽然这对 ${project.version} 工作正常,但 ${maven.build.timestamp} 在过滤时不会被替换.

I am using maven 3.0.4 and would like to make the build timestamp accessible to my application. For this, I'm putting a placeholder in a .properties file and let maven filter on build. While this is working fine for ${project.version}, ${maven.build.timestamp} is not substituted on filtering.

该属性似乎在构建时可用 - 我可以用它来修改工件名称:

The property seems to be available on build - I can use it to modify the artifact name:

${project.artifactId}-${maven.build.timestamp}

那为什么不能用于资源过滤呢?而且,更重要的是,我如何使其可访问?

So why is it not available for resource filtering? And, more importantly, how do I make it accessible?

推荐答案

我发现了这个文章,解释说由于 maven 中的错误,构建时间戳不会传播到过滤.解决方法是将时间戳包装在另一个属性中:

I have discovered this article, explaining that due to a bug in maven, the build timestamp does not get propagated to the filtering. The workaround is to wrap the timestamp in another property:

<properties>
   <timestamp>${maven.build.timestamp}</timestamp>
   <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
</properties>

过滤然后按预期工作

buildTimestamp=${timestamp}

这篇关于如何访问 maven.build.timestamp 进行资源过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆