如何使用新创建的属性文件覆盖某些现有属性?覆盖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