2011-10-12 128 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> 
相关问题