搜索并替换ant文件中的字符串

时间:2015-08-22 04:30:01

标签: ant

您好我想创建一个ant脚本来搜索字符串的出现" DeployName"在rule.template文件中,并将其替换为deploy.config文件中指定的值。我是一个新手或初学者在ant.any帮助表示赞赏。 (1)下面是应从中获取值的配置文件

<config hosts="machineHP" 
environment="local"
tibantHome="C:/internal/tibant"
libLocation="c:/internal/apps"
configHome="C:/internal/apps/config"
projectVersion="1.0"
>
<machineHP >
    <Trade>
        <DeployName>PostTrade</DeployName>
    <Trade>
</machineHP>
</config>

(2)下面是build.xml文件,该文件应调用rule.template文件,并将字符串DeployName替换为上述配置文件中的值

<?xml version="1.0"?>
<project name="candeal" basedir="C:\Documents\Test">
<property name="projname" value="RuleBase" />

<target name="createRuleBase">
    <replace file="C:\Documents\Test\rule.template" token="DeployName"     value="PostTrade" />
</target>
<target name="movefile">
        <copy file="C:\Documents\Test\Rule.template" tofile="C:\Documents\Test\PostTrade.hrb" />
</target>
</project>

1 个答案:

答案 0 :(得分:0)

XmlProperty就是您所需要的。您最终会使用value="PostTrade"替换value="${config.machineHP.Trade.DeployName}"件。

相关问题