![](/img/trans.png)
[英]How to use Ant echo task to append to file when what I'm adding contains CDATA?
[英]AntBuilder ant echo task to append text to a file
我在一个groovy文件中运行ant任务,下面是它的摘录:
def user="USER"
project.ant.echo(file:"/a/b/c/test.properties",
message:"user=${user}", append="true")
我试图通过多次运行脚本将文本追加到文件中。 但是,它没有按预期工作。 以下是当前输出:
cat test.properties
user=USERtrue
如果运行带有append的groovy文件和ant任务,该文件将被覆盖,并在末尾置入true。 如果运行groovy文件和ant任务而没有附加,则该文件将被简单地覆盖。
不知道这里出了什么问题。 任何帮助表示赞赏。
你有没有尝试过:
project.ant.echo( file:"/a/b/c/test.properties",
message:"user=${user}",
append:true )
即:使用append:true
,而不是append="true"
ant.concat
可以是另一种选择(少给一个键:)。
project.ant.concat(destfile:"/some/prop.file", append: true, "user=${user}")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.