请在这里用蚂蚁脚本帮助我执行下面提到的任务,因为我坚持使用它而没有通过。
我有如下属性文件:
AccessSession / OperatorCode =生产
AccessSession /密码=%587931#
依旧......
XML内容如下:(缩短的xml内容)
<application xmlns="http://www.tibco.com/xmlns/ApplicationManagement"
name="PurchaseAdhocBundle">
<description></description>
<contact></contact>
<NVPairs name="Global Variables">
<NameValuePair>
<name>AccessSession/OperatorCode</name>
<value>TM Production</value>
</NameValuePair>
<NameValuePair>
<name>AccessSession/Password</name>
<value>%T3lkom9525#</value>
</NameValuePair>
依旧......
我希望脚本使用属性文件
中给出的实际属性值更新XML文件中的值标记<application xmlns="http://www.tibco.com/xmlns/ApplicationManagement"
name="PurchaseAdhocBundle">
<description></description>
<contact></contact>
<NVPairs name="Global Variables">
<NameValuePair>
<name>AccessSession/OperatorCode</name>
<value>Production</value>
</NameValuePair>
<NameValuePair>
<name>AccessSession/Password</name>
<value>%587931#</value>
</NameValuePair>
答案 0 :(得分:0)
我建议在ANT复制任务中使用filterset将值替换为模板文件。
├── build.properties
├── build.xml
├── src
│ └── template.xml
└── target
└── output.xml
AccessSession/OperatorCode=Production
AccessSession/Password=%587931#
<project name="demo" default="build">
<property file="build.properties"/>
<target name="build">
<copy file="src/template.xml" tofile="target/output.xml">
<filterset>
<filter token="OPERATOR_CODE" value="${AccessSession/OperatorCode}"/>
<filter token="PASSWORD" value="${AccessSession/Password}"/>
</filterset>
</copy>
</target>
</project>
包含可替换标记的模板
<application xmlns="http://www.tibco.com/xmlns/ApplicationManagement"
name="PurchaseAdhocBundle">
<description></description>
<contact></contact>
<NVPairs name="Global Variables">
<NameValuePair>
<name>AccessSession/OperatorCode</name>
<value>@OPERATOR_CODE@</value>
</NameValuePair>
<NameValuePair>
<name>AccessSession/Password</name>
<value>@PASSWORD@</value>
</NameValuePair>
ANT构建生成的输出文件。
<application xmlns="http://www.tibco.com/xmlns/ApplicationManagement"
name="PurchaseAdhocBundle">
<description></description>
<contact></contact>
<NVPairs name="Global Variables">
<NameValuePair>
<name>AccessSession/OperatorCode</name>
<value>Production</value>
</NameValuePair>
<NameValuePair>
<name>AccessSession/Password</name>
<value>%587931#</value>
</NameValuePair>