2016-09-28 27 views
1

這就是我想要做的事:試圖讓這個目標條件

<target name="example"> 
    <if> 
     <equals arg1="${var}" arg2="true" /> 
     <then> 
     <exec executable="/bin/bash"> 
      <arg value="script.sh" /> 
     </exec> 
     </then> 
    </if> 
</target> 

當我執行與螞蟻例如目標我得到這個錯誤:

Problem: failed to create task or type if 
Cause: The name is undefined. 
Action: Check the spelling. 
Action: Check that any custom tasks/types have been declared. 
Action: Check that any <presetdef>/<macrodef> declarations have taken place. 

我真的需要幫助在這裏。我真的很感激它

+0

以下的答案演示如何安裝缺少第三方的依賴:http://stackoverflow.com/questions/34351322/there-isnt-antlib-xml-in-my- ant-contrib-0-3/34361910#34361910 –

回答

1

那是因爲,if是從ant-contrib庫定製的任務。

請確保,ant-contrib庫在您的類路徑中。二進制文件可以從here下載。將ant-contrib jar文件解壓到一個位置。並在下面的taskdef中指定相同。

然後在build.xml的開頭添加任務頁。有關更多詳細信息,請參閱documentation

對於如:

<taskdef resource="net/sf/antcontrib/antcontrib.properties"> 
    <classpath> 
     <pathelement location="/absolute/path/to/ant-contrib-1.0b3.jar" /> 
    </classpath> 
</taskdef> 
+0

Omg非常感謝它的完美運作! – Lost