我得到以下,而这样做的Ant构建:
Build\build.xml:247: Problem: failed to create task or type
for
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.
的build.xml线247是<for param="file">
已经定义的<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
它没有工作。 然后,我特意加入以下但它仍然没有工作。
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${env.ANT_HOME}/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
我有蚂蚁的contrib-1.0b3.jar在C:\软件\ Apache的ANT-1.8.4 \ lib目录。
缺少什么吗?
如果您将AntContrib罐子在$ANT_HOME
/ lib目录下,你真正需要做的是这样的:
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
其实使用<for/>
任务,你需要这样做:
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
请注意,您必须使用antlib.xml
而不是antcontrib.properties
。 阅读安装方向非常谨慎。 这很容易错过。
如果你是在一个项目组这样做,我建议你把你的蚂蚁contrib.jar在您的项目。 然后将它们添加到您的项目在你的版本控制系统。 这样一来,其他的开发者可以使用你的构建与蚂蚁的contrib任务,而无需下载蚂蚁的contrib罐子,并在其$ ANT_HOME目录中安装它自己。
比方说,你创建一个目录名为ant-contrib.dir
也放到了你的项目的根目录,然后把蚂蚁的contrib罐子该文件夹中。 只要把这个在您的项目:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<fileset dir="${basedir}/ant-contrib.dir"/>
</classpath>
</taskdef>
蚂蚁需要注意的依赖关系。 以下是大卫·W公司的回答更简洁的版本。 以下相当于添加到您的蚂蚁项目:
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="relative/path/to/ant-contrib-1.0b3.jar"/>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="relative/path/to/ant-contrib-1.0b3.jar"/>
文章来源: Apache ant does not recognize 'for' task/macro, although I have added ant-contrib via taskdef