ANT使用具有属性的文件替换指定文件中的字符串 [英] ANT replacing strings in specified files using file with properties

查看:106
本文介绍了ANT使用具有属性的文件替换指定文件中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在dev.properties文件中有一个属性,它们看起来像这样:

I have a properties in file dev.properties and they look like this:

test.url=https://www.example.com/
[...]

,并且在项目文件中有一个标记[[test.url]],我想替换为 https://www.example.com/.我只想在dev.properties中定义所有标记,并在构建脚本中使用它们,但不修改构建脚本,我想在指定的文件(例如* .php,*.html等)中替换这些标记.

and in project files there is a token [[test.url]] which I want to replace by https://www.example.com/. I just want to define all tokens in dev.properties and use them in build script, but without modifying build script and I want to replace those tokens in a specified files like *.php, *.html, etc.

有人可以给我一些建议吗?谢谢.

Can someone give me a suggestions how to do it? Thanks.

推荐答案

尝试一下:

<copy file="input.txt" tofile="output.txt">
   <filterchain>
   <replaceregex pattern="\$\{" replace="{" />
   <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
        <param type="propertiesfile" value="properties.txt"/>
        <param type="tokenchar" name="begintoken" value="{"/>
        <param type="tokenchar" name="endtoken" value="}"/>
    </filterreader>
    </filterchain>
</copy>

在这里建立: Ant替换属性文件中的令牌

这篇关于ANT使用具有属性的文件替换指定文件中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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