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?
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With