从 Apache 的 Ant PropertyFile 任务中删除日期注释 [英] Removing Date Comment from Apache's Ant PropertyFile Task

查看:20
本文介绍了从 Apache 的 Ant PropertyFile 任务中删除日期注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在构建脚本中使用下面显示的 propertyfile 任务:

I'm using the propertyfile task shown below in my build script:

<target name="build-brand" depends="-init" description="Adds version information to branding files.">
    <propertyfile file="${basedir}/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties">
        <entry key="currentVersion" value="${app.windowtitle} ${app.version}" />
    </propertyfile>
</target>

任务按预期工作,除了每次构建项目时,Bundle.properties 文件的日期注释行都会更新为当前时间戳.即使 app.version 变量未更改并导致对仅包含以下差异的版本控制的不必要提交,也会发生这种情况:

The task works as expected, except that each time I build the project, the date comment line of the Bundle.properties file is updated with the current time stamp. This occurs even if the app.version variable does not change and results in an un-necessary commit to version control consisting solely of the following diff:

--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -1,4 +1,4 @@
-#Thu, 22 Jul 2010 15:05:24 -0400
+#Tue, 10 Aug 2010 13:38:27 -0400

如何防止在 .properties 文件中添加或删除此日期注释?我在propertyfile嵌套entry元素中考虑过删除操作,但是需要key值.

How can I prevent addition of or remove this date comment from the .properties file? I considered a delete operation in propertyfile nested entry element, but a key value is required.

推荐答案

这不是一个很好的解决方案,但如何一起删除评论?

This isn't a great solution, but how about removing the comment all together?

<target name="build-brand" depends="-init" description="Adds version information to branding files.">
    <propertyfile file="${basedir}/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties">
        <entry key="currentVersion" value="${app.windowtitle} ${app.version}" />
    </propertyfile>
    <replaceregexp file="${basedir}/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties" match="^#.*\n" replace=""/>
</target>

这篇关于从 Apache 的 Ant PropertyFile 任务中删除日期注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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