35

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?

James Raitsev
  • 92,517
  • 154
  • 335
  • 470
kores
  • 351
  • 1
  • 3
  • 4

2 Answers2

45

The echo task in ANT is able to write to files

<echo file="output.txt" append="true">
   abc=${abc}
</echo>
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
30

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.

Jarekczek
  • 7,456
  • 3
  • 46
  • 66