gpt4 book ai didi

java - 从 Apache 的 Ant PropertyFile 任务中删除日期注释

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:51:00 25 4
gpt4 key购买 nike

我在构建脚本中使用如下所示的属性文件任务:

<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 变量未更改并导致不必要地提交到仅包含以下差异的版本控制,也会发生这种情况:

--- 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值。

最佳答案

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

<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>

关于java - 从 Apache 的 Ant PropertyFile 任务中删除日期注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3452122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com