I'm loading ant-contrib through a taskdef Then I'm checking with the available task that the 'IfTask' is created. This fails
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="/path/to/ant/contrib.jar"/>
<condition property="IfTaskAvailable">
<available classname="net.sf.antcontrib.logic.IfTask"/>
</condition>
<fail message="The If task is not defined" unless="IfTaskAvailable"/>
The available task does not seem to check using the same class loader used by the taskdef ?
EDIT after Oleg Pavliv answer After a bit of gidding this effectively works. I should have been clearer in my question.
This works in Ant, but this does not work when calling ant from Gradle, i.e. in a gradle build:
ant.taskdef(uri:'antlib:net.sf.antcontrib', resource:'net/sf/antcontrib/antcontrib.properties', classpath: '/path/to/ant/contrib.jar')
ant.available(classname:'net.sf.antcontrib.logic.IfTask')
Probably the
/path/to/ant/contrib
is not correctOn my computer it works
The output
EDIT: If you call it from gradle you should specify the
classpath
inavailable
as well.