Using a custom task in Ant

25 May 2008

It is assumed that you have already defined a custom Ant task and wish to use it. In this post, I will show you how to do so.

You first need to definethe task by giving it a name and telling Ant the classfile that implements it and any classpath setting required to locate that classfile. This is done using the taskdef task, like so:

<taskdef name="fileparser"
classname="FileParser"
classpath="."/>

Now the task can now be used in the same way as Ant’s core tasks. The following example shows how to use a custom task:

<?xml version="1.0"?>
<project name="CustomTaskExample" default="main" basedir=".">
<taskdef name="fileparser"
classname="FileParser"
classpath="."/>
<target name="main">
<filesorter file="input.txt" tofile="output.txt"/>
</target>
</project>

del.icio.us:Using a custom task in Ant  digg:Using a custom task in Ant  spurl:Using a custom task in Ant  wists:Using a custom task in Ant  simpy:Using a custom task in Ant  newsvine:Using a custom task in Ant  blinklist:Using a custom task in Ant  furl:Using a custom task in Ant  reddit:Using a custom task in Ant  fark:Using a custom task in Ant  blogmarks:Using a custom task in Ant  Y!:Using a custom task in Ant  smarking:Using a custom task in Ant  magnolia:Using a custom task in Ant  segnalo:Using a custom task in Ant  gifttagging:Using a custom task in Ant

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Using a custom task in Ant

Leave a Reply