ANT:使用条件标签,<IF>

标签 ant tags if-statement

我想做这样的事情

<target name="clean" description="clean">
    <if>
        <available file="${build}" type="dir" />
        <then>
            <delete dir="${build}" />
        </then>
    </if>
</target>

根据 suggestions在 stackoverflow.com 上找到,我下载了 ant-contrib-1.0b3.jar 并将其放入我的路径中

Classpath

此外,在 Ant Build 配置下,在类路径中,我有
enter image description here

运行我的 ANT 脚本时,我仍然得到
BUILD FAILED
C:\Repositories\blah\build.xml:60: 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 <presetdef>/<macrodef> declarations have taken place.

我错过了什么?请指教

最佳答案

或者,一次可以在您的 ANT 脚本中包含以下行

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

只要ant-contribs就在你的路上,不需要其他任何东西

这个解决方案更干净一点,作为一个 获得对所有标签的访问权,不仅仅是手动指定的那些

关于ANT:使用条件标签,<IF>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6336792/

相关文章:

java - 无法使用 ant 从 jar 启动 main()

VIM 和自定义标记

javascript - 根据另一个字段的条件隐藏 SharePoint 中的字段

c - 编程查找元音,If 语句未分配正确的值

haskell - Haskell 中的 Guard、if-then-else 与 case

gradle - 如何获得 “gradle”具有与 “ant”类似的输出详细信息?

ant: srcdir 属性必须非空

ant - 在 ant 脚本中使用最近的 Rhino

algorithm - 词干提取——代码示例还是开源项目?

python - 如何在Python编程中查看和编辑元标签