如何使用新創建的屬性文件覆蓋某些現有屬性?覆蓋ANT屬性文件
這裏是所需要的結構:
initially load Master.properties
generate new.properties
load new.properties and master.properties
run master.xml (ANT script)
的想法是,Master.properties生成應由new.properties更換一些產品版本。但是,Master.properties中的其他屬性應保持不變。
閱讀this沒有幫助,因爲我不知道我怎樣才能加載new.properties文件
編輯這裏是Ant腳本:
<project name="nightly_build" default="main" basedir="C:\Work\NightlyBuild">
<target name="init1">
<sequential>
<property file="C:/Work/NightlyBuild/master.properties"/>
<exec executable="C:/Work/Searchlatestversion.exe">
<arg line='"/SASE Lab Tools" "${Product_Tip}/RELEASE_"'/>
</exec>
<sleep seconds="10"/>
<property file="C:/Work/new.properties"/>
</sequential>
</target>
<target name="init" depends="init1">
<sequential>
<echo message="The product version is ${Product_Version}"/>
<exec executable="C:/Work/checksnapshot.exe">
<arg line='-NightlyBuild ${Product_Version}-AppsMerge' />
</exec>
<sleep seconds="10"/>
<property file="C:/Work/checksnapshot.properties"/>
<tstamp>
<format property="suffix" pattern="yyyy-MM-dd.HHmm"/>
</tstamp>
</sequential>
</target>
<target name="main" depends="init">
<echo message="loading properties files.." />
<echo message="Backing up folder" />
<move file="C:\NightlyBuild\NightlyBuild" tofile="C:\NightlyBuild\NightlyBuild.${suffix}" failonerror="false" />
<exec executable="C:/Work/sortfolder.exe">
<arg line="6" />
</exec>
<exec executable="C:/Work/NightlyBuild/antc.bat">
</exec>
</target>
</project>
在上面的腳本,<exec executable="C:/Work/NightlyBuild/antc.bat">
將運行碩士。 xml ANT腳本。這Master.xml將加載Master.properties
:
<project name="Master ANT Build" default="main" >
<taskdef name="CFileEdit" classname="com.ANT_Tasks.CFileEdit"/>
<!-- ========================================================== -->
<!-- init: sets global properties -->
<!-- ========================================================== -->
<target name="init">
<property environment="env"/>
<!-- ========================================================== -->
<!-- Set the timestamp format -->
<!-- ========================================================== -->
<property file="Master.properties"/>
...
</project>
請參閱我的編輯以獲得更好的理解。作爲要求的一部分,我無法分割這個Master.properties – jeremychan 2011-06-08 09:11:20
爲什麼你需要加載目標init1中的Master.properties?爲什麼你需要在new.properties之前加載它? – sudocode 2011-06-08 09:34:33
哎呀抱歉,我編輯$ {Product_Tip}應該在 – jeremychan 2011-06-08 09:40:16