ANT:使用条件标记,<如果> [英] ANT: Using conditional tags, <IF>

查看:103
本文介绍了ANT:使用条件标记,<如果>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我愿做这样的事情。

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

作为每个<一href=\"http://stackoverflow.com/questions/1163998/do-i-have-any-way-to-check-the-existence-of-a-directory-in-ant-not-a-file\">suggestions在stackoverflow.com发现,我下载蚂蚁的contrib-1.0b3.jar,并把它放到我的路径

As per suggestions found on stackoverflow.com, i downloaded ant-contrib-1.0b3.jar and put it into my path

此外,在Ant构建配置,在类路径中,我有

Additionally, under Ant Build configuration, in classpath, i have

当我运行脚本ANT,我仍然得到

When running my ANT script, i still get

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脚本以下行

Alternately, once can include the following line in your ANT script

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

只要蚂蚁贡献是在你的路径,没有别的需要

As long as ant-contribs is in your path, nothing else is needed

这解决方案是一个有点清洁,为一体的获得访问所有的标签,手动指定的不只是那些

This solution is a bit cleaner, as one gains access to ALL the tags, not just the ones manually specified

这篇关于ANT:使用条件标记,&LT;如果&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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