2012-09-14 62 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