2011-10-12 166 views

回答

5

在目標上使用if屬性,例如:

<project name="test" default="init"> 
    <target name="init" if="${path}"> 
     <!--This will only execute if ${path} is defined from the command line--> 
    </target> 
</project> 

第二種方案:更詳細的

<project name="test" default="init"> 
    <target name="init"> 
     <fail message="Path is not set! Exiting ant script!"> 
     <condition> 
      <not> 
      <isset property="${path}"/> 
      </not> 
     </condition> 
     </fail> 
    </target> 
</project> 
相關問題