我在文件 dev.properties 中有一个属性,它们看起来像这样:
test.url=https://www.example.com/
[...]
在项目文件中有一个令牌 [[test.url]] 我想将其替换为https://www.example.com/。我只想在 dev.properties 中定义所有标记并在构建脚本中使用它们,但不修改构建脚本,并且我想替换指定文件(如 *.php、*.html 等)中的这些标记。
有人可以给我建议如何去做吗?谢谢。
尝试这个:
<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 替换属性文件中的令牌
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)