Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I append some text at the end of a file using Ant?

Tags:

In one of the configuration files for my project I need to append some text. I am looking for some options to do this using Ant.

I have found one option - to find something and replace that text with the new text, and the old values. But it does not seems to be promising, as if in future someone changes the original file the build will fail.

So, I would like my script to add the text at the end of the file.

What options do I have for such a requirement?

like image 693
Vijay Shanker Dubey Avatar asked Sep 17 '10 04:09

Vijay Shanker Dubey


1 Answers

Use the echo task:

<echo file="file.txt" append="true">Hello World</echo> 

EDIT: If you have HTML (or other arbitrary XML) you should escape it with CDATA:

<echo file="file.txt" append="true"> <![CDATA[   <h1>Hello World</h1> ]]> </echo> 
like image 161
Michael Pilat Avatar answered Sep 19 '22 23:09

Michael Pilat