Java 从Apache'中删除日期注释;s Ant属性文件任务
我正在使用构建脚本中显示的propertyfile任务:Java 从Apache'中删除日期注释;s Ant属性文件任务,java,ant,Java,Ant,我正在使用构建脚本中显示的propertyfile任务: <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">
<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>
如何防止在.properties文件中添加或删除此日期注释?我考虑在propertyfile嵌套条目元素中执行删除操作,但需要键值。尝试:
编辑:这可能行不通:(。看起来罪魁祸首实际上是:
接下来,将始终显示注释行
写的,由ASCII码组成的#
字符,当前日期和时间
(好像是由toString方法生成的
当前时间的日期),以及
由生成的行分隔符
作家
这不是一个很好的解决方案,但是把评论一起删除怎么样
<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>
如果需要在文件中放置单个属性,只需使用echo即可:
<echo output="somefiles.properties">lastmodified=${lastmodified}</echo>
lastmodified=${lastmodified}
um.我检查了源代码,似乎没有办法解决这个问题。LayoutPreservingProperties类(默认情况下使用)和Properties类(UseJDKProperty设置为true时使用)在其存储方法中都有此项。通过省略byline=“true”其他注释已保留作为管理员:replaceregexp仍保留一个空行。您能告诉我如何删除该行而不保留一个空行吗?@Anand我编辑了replaceregexp
行以完全删除日期行。通过此更改,如果您的属性文件已包含新条目,则不会进行任何更改除了更改时间戳之外,所有其他注释(包括文件开头的注释)都将保留。
<echo output="somefiles.properties">lastmodified=${lastmodified}</echo>