का उपयोग कर एक एक्सएमएल फ़ाइल में संपत्ति को बदलें, मैं एएनटी स्क्रिप्ट का उपयोग कर build.xml फ़ाइल में संस्करण संख्या को प्रतिस्थापित करने का प्रयास कर रहा हूं।एएनटी
मैंने विभिन्न दृष्टिकोणों की कोशिश की है, जवाब के लिए StackOverflow की खोज की और फिर से खोज की लेकिन सटीक क्वेरी नहीं मिल सका। अब के रूप में यू देख सकते हैं संस्करण कल तिथि है
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<project name="feature" default="main" basedir=".">
<target name="init">
<property name="Version" value="1.0.0.20120327"/>
</target>
<target name="main" depends="init">
<description>Main target</description>
</target>
</project>
:
इसलिए यहाँ मेरी xml फ़ाइल है। मुझे इसे वर्तमान तारीख से बदलना होगा।
यहाँ मैं क्या कोशिश की है है:
<target name="replace">
<tstamp >
<format property="touch.time" pattern="yyyyMMdd"/>
</tstamp>
<property name="Feature.dir" location="../feature" />
<!--Didnt Work-->
<copy file="${Feature.dir}\build.xml" tofile="${Feature.dir}\build1.xml"
filtering="yes" overwrite="yes">
<filterset>
<filter token="Version" value="1.0.0.${touch.time}"/>
</filterset>
</copy>
<!--Didnt work
<replacetoken><![CDATA[<property name="Version" value=""/>]]>
</replacetoken>
<replacevalue><![CDATA[<property name="Version"value="1.0.0.${touchtime}" />]]>
</replacevalue>
-->
<!-- Didnt work
<copy file="${Feature.dir}/build.xml" tofile="${Feature.dir}/build1.xml" >
<filterchain>
<tokenfilter>
<replaceregex pattern="^[ \t]*Version[ \t]*=.*$"
replace="Version=1.0.0.${touch.time}"/>
</tokenfilter>
</filterchain>
</copy>
-->
</target>
काम किया धन्यवाद। लेकिन सिर्फ एक सवाल है। क्या होगा यदि मैं एक ही फाइल में यह परिवर्तन करना चाहता हूं? मैंने कोशिश की: <कॉपी फ़ाइल = "$ {Feature.dir} \ build.xml" tofile = "$ {Feature.dir} \ build.xml" फ़िल्टरिंग = "हाँ" ओवरराइट = "हाँ"> नहीं काम – sloggers1894
कोई चिंता नहीं। मेरा संपादित उत्तर देखें। – Synesso