我如何在追加使用Ant文件的末尾一些文本? [英] How do I append some text at the end of a file using Ant?

查看:226
本文介绍了我如何在追加使用Ant文件的末尾一些文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目的配置文件,我需要追加一些文本之一。
我找了一些选项来做到这一点使用Ant。

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?

推荐答案

使用回声任务:

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

编辑:如果你有HTML(或其他任意XML)你应该逃避它 CDATA

<echo file="file.txt" append="true">
<![CDATA[
  <h1>Hello World</h1>
]]>
</echo>

这篇关于我如何在追加使用Ant文件的末尾一些文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆