Question

I am running ant task in a groovy file and below is the snippet of it:

def user="USER"
project.ant.echo(file:"/a/b/c/test.properties",  
message:"user=${user}", append="true")

I am trying to append text to the file, by running the script multiple times. However it is not working as expected. Below is the current output:

cat test.properties
user=USERtrue

If the run the groovy file and ant task with append, the file is overwritten and it puts true at the end. If the run the groovy file and ant task without append, the file is simply overwritten.

Not sure what is wrong here. Any help is appreciated.

Was it helpful?

Solution

Have you tried:

project.ant.echo( file:"/a/b/c/test.properties",
                  message:"user=${user}",
                  append:true )

ie: use append:true, not append="true"

OTHER TIPS

ant.concat can be another option (one less key to give :).

project.ant.concat(destfile:"/some/prop.file", append: true, "user=${user}") 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top