How to write a variable in to file in ant?

2020-05-20 02:11发布

问题:

i have a variable abc and had the value this is ant script. This abc variable will keep on changing.

Using ANT script, how can i write the value out to the file?

回答1:

The echo task in ANT is able to write to files

<echo file="output.txt" append="true">
   abc=${abc}
</echo>


回答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.



标签: ant