How to store Apache Ant property value in file

2019-04-30 03:00发布

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.

标签: ant
2条回答
时光不老,我们不散
2楼-- · 2019-04-30 03:35

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.

查看更多
smile是对你的礼貌
3楼-- · 2019-04-30 03:45

You can use the echo task.

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

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

查看更多
登录 后发表回答