ANT: Using conditional tags, <IF>

Viewed 35711

I would like to do something like this

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

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

Classpath

Additionally, under Ant Build configuration, in classpath, i have enter image description here

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.

What am i missing? Please advise

6 Answers

export ANT_HOME=/path/to/ant/apache-ant-1.8.2 I couldn't get it to work until I had ANT_HOME set properly. Java kept picking another ant installed on the box.

Related