<target name="init">
<mkdir dir="${build.dir}" />
<if>
<available file="../war" type="dir"/>
<then></then>
<else>
<mkdir dir="../war" />
</else>
</if>
</target>
This is the code i am using to check if a folder exists, but getting the following error:
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
I have copied ant-contrib.jar in ANT_HOME/lib. where am i goin wrong?
Given the example above, you can greatly simplify it:
…since the
mkdirtask does nothing if the folder exists (see documentation).If you’re asking how to use
ifandthenin ant, I recommend picking another example since each action in Ant tends to have its own conditionals built in.