Ant 的 replace 操作

replace 可以替换某个文件中的字符串。

<?xml version="1.0" encoding="UTF-8"?>
<project name="testCondition">
    <replace file="testfile1.txt"    token="hello"     value="world"/>
</project>

结果就把 testfile1.txt 中的 "hello" 替换成了 "world".

也可以批量处理:

<?xml version="1.0" encoding="UTF-8"?>
<project name="testCondition">
    <replace dir="." includes="*.txt" encoding="UTF-8">
        <replacefilter token="this" value="that"/>
        <replacefilter token="o" value="00"/>
    </replace>
</project>

就把当前文件夹下面所有 txt 文件按照指定的 filter 替换了。

原文地址:https://www.cnblogs.com/backpacker/p/2846879.html