This is what I'm trying to do:
<target name="example">
<if>
<equals arg1="${var}" arg2="true" />
<then>
<exec executable="/bin/bash">
<arg value="script.sh" />
</exec>
</then>
</if>
</target>
And when I execute the target with ant example I get this error:
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 really need help in here. I would really appreciate it
That is because, if
is custom task from ant-contrib
library.
Make sure, ant-contrib library in your class path. Binaries can be downloaded from here. Extract the ant-contrib jar file to a location. And specify the same in below taskdef.
Then add the taskdef at the beginning of the build.xml. Refer documentation for more details.
For eg:
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="/absolute/path/to/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>