Search code examples
apacheantant-contrib

If isset in apache ant is failing


I am trying to check if a property exists in ant with the following:

<target name="test">
    <property name="testproperty" value="1234567890"/>
    <if>
        <isset property="testproperty"/>
        <then>
            <echo message="testproperty exists"/>
        </then>
        <else>
            <echo message="testproperty does not exist"/>
        </else>
    </if>
</target>

The result is a failure with the message:

build.xml:536: 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.

I must be doing something wrong with isset as the following runs smoothly:

<target name="test">
    <property name="testproperty" value="1234567890"/>
    <echo message="'${testproperty}'"/>
</target>

Please advice :)


Solution

  • Apparently I was missing the ant-contrib jar file that can be found here:
    http://ant-contrib.sourceforge.net/