Apache ant 无法识别“for"任务/宏,尽管我已通过 taskdef 添加了 ant-contrib [英] Apache ant does not recognize 'for' task/macro, although I have added ant-contrib via taskdef

查看:38
本文介绍了Apache ant 无法识别“for"任务/宏,尽管我已通过 taskdef 添加了 ant-contrib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做 ant build 时得到关注:

I am getting following while doing ant build:

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 行是

build.xml line 247 is <for param="file">

已经定义了<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>,没有用.然后我专门添加了以下内容,但仍然无法正常工作.

Already defined <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>, it didn't work. Then I specifically added following but it is still not working.

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
        <classpath>
            <pathelement location="${env.ANT_HOME}/lib/ant-contrib-1.0b3.jar"/>
        </classpath>
    </taskdef>

我在 C:\Softwares\apache-ant-1.8.4\lib 目录中有 ant-contrib-1.0b3.jar.
这里缺少什么?

I have ant-contrib-1.0b3.jar at C:\Softwares\apache-ant-1.8.4\lib directory.
What is missing here?

推荐答案

如果你把 AntContrib jar 放在 $ANT_HOME/lib 目录下,你真正需要做的就是:

If you placed the AntContrib jar in $ANT_HOME/lib directory, all you really need to do is this:

<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

实际上要使用<for/>任务,需要这样做:

Actually to use the <for/> task, you need to do this:

<taskdef resource="net/sf/antcontrib/antlib.xml"/>

请注意,您必须使用 antlib.xml 而不是 antcontrib.properties.仔细阅读安装说明.很容易错过.

Note you have to use antlib.xml and not antcontrib.properties. Read the Installation directions very carefully. It's easy to miss.

如果你在一个小组项目中这样做,我建议你把你的 ant-contrib.jar 放在你的项目中.然后将它们添加到您的版本控制系统中的项目中.这样,其他开发人员就可以将您的构建与 ant-contrib 任务一起使用,而无需自己下载 ant-contrib jar 并将其安装在他们的 $ANT_HOME 目录中.

If you are doing this in a group project, I recommend that you put your ant-contrib.jar in your project. THen add them to your project in your version control system. That way, other developers can use your build with the ant-contrib tasks without downloading the ant-contrib jar and installing it in their $ANT_HOME directory themselves.

假设您创建一个名为 ant-contrib.dir 的目录并将其放在项目的根目录中,然后将 ant-contrib jar 放在该文件夹中.只需将其放入您的项目中即可:

Let's say you create a directory called ant-contrib.dir and put that in the root of your project, then put the ant-contrib jar in that folder. Just put this in your project:

<taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
          <fileset dir="${basedir}/ant-contrib.dir"/>
    </classpath>
</taskdef>

这篇关于Apache ant 无法识别“for"任务/宏,尽管我已通过 taskdef 添加了 ant-contrib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆