taskdef
which includes a
classpath. Here is a simple example:
<project name="test" default="all" basedir="."> <target name="init"> <javac srcdir="tasksource" destdir="tasksource"/> <jar jarfile="mytasks.jar" basedir="tasksource"> <exclude name="**/*.java"/> </jar> <taskdef name="customtask" classname="com.mycom.MyCustomTask" classpath="mytasks.jar"/> </target> <target name="all" depends="init"> <customtask someparam="val"/> </target> </project>The advantage is that no special preparation is needed to begin using the script; it is entirely self-contained. You can develop the tasks inside the IDE too if you like, and the script will compile them for you automatically.
classpath
attribute is missing from the taskdef
. In this case you
need to add the tasks to your classpath before starting Ant on the
command line.
Inside the IDE, it also works to start the IDE with the tasks in its classpath. But a much better idea is to just mount the filesystem containing the source code for your tasks in the IDE's Filesystems tab. You can use the IDE to interactively develop and compile the tasks; the Ant script will automatically look for task definitions in your filesystems every time it is run.