How to store Apache Ant property value in file

南笙酒味 提交于 2019-12-22 08:05:06

问题


I need to modify a (xml-)file from Apache Ant. "loadfile" task allows to load the file's content in a property. But how to store the property's value back to a file after its (property) modification?

Of course I could write custom task to perform this operation but I would like to know if there's some existing implementation.


回答1:


You can use the echo task.

<echo file="${fileName}" message="${xmlProperty}"/>

The echoxml task might be of interest to you as well.




回答2:


Use propertyfile task. An example taken from ant manual:

<propertyfile file="my.properties">
  <entry  key="abc" value="${abc}"/>
</propertyfile>

This may be better than echo as it updates the properties file with a given value, while echo appends to or overwrites the whole file.



来源:https://stackoverflow.com/questions/262015/how-to-store-apache-ant-property-value-in-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!