2011-06-01 101 views
1

以下是我的ant腳本:問題ant腳本性能

<project name="nightly_build" default="main" basedir="C:\Work\6.70_Extensions\NightlyBuild"> 
    <target name="init"> 
     <sequential> 
      <exec executable="C:/Work/Searchlatestversion.exe"> 
       <arg line='"/SASE Lab Tools" "6.70_Extensions/6.70.102/ANT_SASE_RELEASE_"'/> 
      </exec> 
      <property file="C:/Work/latestbuild.properties"/> 
      <sleep seconds="10"/> 
      <echo message="The product version is ${Product_Version}"/> 
      <exec executable="C:/Work/checksnapshot.exe"> 
       <arg line='"ANT_SASE_RELEASE_${Product_Version}_SASE Lab Tools-NightlyBuild" ANT_SASE_RELEASE_${Product_Version}_AnalyzerCommon-NightlyBuild ${Product_Version}-AppsMerge' /> 
      </exec> 
      <property file="C:/Work/checksnapshot.properties"/> 
      <tstamp> 
       <format property="suffix" pattern="ddMMyyyyHHmm"/> 
      </tstamp> 
     </sequential> 
    </target> 
    <target name="main" depends="init"> 
      <echo message="loading properties files.." /> 
      <sleep seconds="10"/> 
      <echo message="Backing up folder" /> 
      <move file="C:\NightlyBuild\NightlyBuild" tofile="C:\NightlyBuild\NightlyBuild.${suffix}" failonerror="false" /> 
      <parallel> 
       <exec executable="C:/Work/sortfolder.exe"> 
        <arg line="6" /> 
       </exec> 
       <exec executable="C:/Work/6.70_Extensions/NightlyBuild/antc.bat"> 
       </exec> 
      </parallel> 
    </target> 
</project> 

基本上順序是這樣的:

  1. 我將運行Searchlatestversion.exelatestbuild.properties
  2. 使用latestbuild.properties我將獲得${Product_Version}並且希望允許checksnapshot.exe訪問latestbuild.properties並獲得${Product_Version}
  3. checksnapshot.exe然後將生成checksnapshot.properties這將然後在主antc.bat

目標使用我做錯了什麼在這裏?似乎${Product_Version}沒有收到好checksnapshot.exe

回答

1

您似乎有一個硬編碼的等待期爲10秒,Searchlatestversion寫出您的文件。如果可執行文件在該時間內沒有完成,${Product_Version}無法從文件讀取。

您是否考慮過使用Waitfor Ant任務?顧名思義,這將等待一定的條件,然後才能讓其餘任務進展。你可以做類似

<property name="props.file" value="C:/Work/latestbuild.properties"/> 
<waitfor maxwait="10" maxwaitunit="second"> 
    <available file="${props.file}"/> 
</waitfor> 
<property file="${props.file}"/> 
0

Searchlatestversion.exe產生文件C:/Work/latestbuild.properties?

如果是這樣,你應該不睡覺/等待之前你加載該屬性文件?

你有這樣的:

 <exec .../> 
     <property file="C:/Work/latestbuild.properties"/> 
     <sleep seconds="10"/> 

如果你沒有這樣的:

 <exec ... /> 
     <sleep seconds="10"/> 
     <property file="C:/Work/latestbuild.properties"/>