Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a variable in to file in ant?

Tags:

ant

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?

like image 720
kores Avatar asked Jan 12 '11 08:01

kores


People also ask

What is echo in ant?

Echoes a message to the current loggers and listeners which means System. out unless overridden. A level can be specified, which controls at what logging level the message is filtered at.

Which task is used to load the file into a property?

This task is used to load file into a property. It works on files and provides a srcFile attribute for ease. It uses default encoding current locale unless other one is specified.


2 Answers

The echo task in ANT is able to write to files

<echo file="output.txt" append="true">    abc=${abc} </echo> 
like image 191
Mark O'Connor Avatar answered Sep 23 '22 11:09

Mark O'Connor


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.

like image 42
Jarekczek Avatar answered Sep 23 '22 11:09

Jarekczek