2012-09-14 66 views
3

我有一些導入另一個的ant文件。具體來說build.xml進口一個project_default.xml。當我嘗試做一個生成我得到以下錯誤:找到導致螞蟻失敗的原因

Buildfile: C:\myproject\build.xml [taskdef] Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.

BUILD FAILED C:\myproject\build.xml:14: The following error occurred while executing this line: C:\myproject\project_default.xml:17: 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 /declarations have taken place.

行報告17如下:

<if> 
<contains string="${env.PROJECT_SELECTION}" substring="env.PROJECT_SELECTION" /> 

我還添加在build.xml如下:

<taskdef resource="net/sf/antcontrib/antcontrib.properties"> 
    <classpath> 
    <pathelement location="D:\UserData\ant-contrib-0.6-bin\lib\ant-contrib-0.6.jar"/> 
    </classpath> 
</taskdef> 

但得到了同樣的錯誤。想知道這裏有什麼問題嗎?

回答

2

與螞蟻版本> 1.6,你應該使用 「淨/平方英尺/ antcontrib/antlib.xml」 代替 「淨/平方英尺/ antcontrib/antcontrib.properties」

這樣的taskdef改成這樣:

<taskdef resource="net/sf/antcontrib/antlib.xml"> 
    <classpath> 
    <pathelement location="D:\UserData\ant-contrib-0.6-bin\lib\ant-contrib-0.6.jar"/> 
    </classpath> 
</taskdef> 

歡呼聲,

+0

複製粘貼你的代碼,仍然會得到同樣的錯誤.'不能從資源淨/ sf/antcontrib/antcontrib.properties中加載定義。' – Jim

+0

嗨,你的build.xml文件中的任務是在執行taskdef?是真正位於「D:\ UserData \ ant-contrib-0.6-bin \ lib \ ant-contrib-0.6.jar」的jar文件嗎?而不是明確地定義它,你也可以將它移動到你的ant安裝目錄下的lib目錄中......這樣你就不需要 ... Naytzyrhc

0

首先要檢查的是你有ant-contrib jar路徑corrext。運行螞蟻與-verbose以獲得更多關於它在做什麼以及它試圖從哪裏加載的任務的信息。

你在哪裏添加了taskdef?如果你在目標外使用<if>任務,那麼你需要在它之前的taskdef,也在目標之外。如果你在一個目標中使用它,那麼taskdef可以在調用之後(文本),只要它在目標之外或者在依賴關係順序之前運行的目標中。

+0

這不是我的ant文件,我看到''不是'taskdef'或'target'的一部分 – Jim