ant - Apache ant 无法识别 'for' 任务/宏,虽然我已经通过 taskdef 添

我在进行 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 行是 <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>

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

最佳答案

如果您将 AntContrib jar 放入 $ANT_HOME/lib 目录,你真正需要做的就是:

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

其实用<for/>任务,你需要这样做:

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

请注意,您必须使用 antlib.xml而不是 antcontrib.properties .阅读 Installation directions很小心。很容易错过。

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

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

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

关于ant - Apache ant 无法识别 'for' 任务/宏,虽然我已经通过 taskdef 添加了 ant-contrib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12407637/

相关文章:

android - 如何生成 R.java

android - crashlytics android studio gradle 构建失败

build - 使用测试报告聚合 gradle 多项目测试结果

build - 您如何启动并运行构建服务器?

iphone - 我可以将 "Build Active Architecture Only"设置为

build - CMake 的新手想知道哪些尘土飞扬的角落?

javascript - 使用 Jenkins 和 Apache Ant 运行 QUnit 测试?

java - 如何告诉 ant 使用特定的 javac 可执行文件进行构建?

.net - nuget安装退出代码9009

build - VSTS 构建所有分支