2010-06-22 49 views
3

如果設置了屬性,是否可以在ant的build.xml中導入文件,如果不是,則不要導入它。ant條件導入

有沒有其他方法使用ant-contrib如果任務。

謝謝

回答

2

是的,你可以。 例如:

<target name="importFile" depends="myProperty.check" if="myPropertyIsSet"> 
    <echo>Import my file here</echo> 
</target> 

<target name="myTarget.check"> 
    <condition property="myPropertyIsSet"> 
     <and> 
      <!-- Conditions to check if my property is set. --> 
     </and> 
    </condition> 
</target> 

可用的條件在Apache Ant Manual說明。

+0

謝謝你會試一試 – user373201 2010-06-22 16:58:05

+2

這沒有用。從ant 1.7開始,你不能在目標中使用導入。它必須是一個頂級的任務 – user373201 2010-06-22 17:11:50

+0

Ouch,我的錯。另外,導入任務的可選屬性不夠嗎? – uthark 2010-06-22 17:36:23