An optional task is a task which typically requires an external library to function.
Use Ant's own mechanisms for adding libraries:
<?xml version="1.0"?>
<project name="OwnTaskExample" default="main" basedir=".">
<taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask"/>
<target name="main">
<mytask message="Hello World! MyVeryOwnTask works!"/>
</target>
</project>
declare a bundle of tasks using a properties-file holding these taskname-ImplementationClass-pairs and <taskdef>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" /> <for ... />
declare a bundle of tasks using a xml-file holding these taskname-ImplementationClass-pairs and <taskdef>
<taskdef resource="net/sf/antcontrib/antlib.xml" /> <for ... />
declare a bundle of tasks using an xml-file named antlib.xml, XML-namespace and antlib: protocol handler
<project xmlns:ac="antlib:net.sf.antcontrib"/> <ac:for ... />