Вопрос

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.

Это было полезно?

Решение

Have you tried:

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

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

Другие советы

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

project.ant.concat(destfile:"/some/prop.file", append: true, "user=${user}") 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top