Using a custom task in Ant
25 May 2008It 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>
Related Posts:
- Defining custom tasks in ANT
- Defining own annotation type - II
- Custom annotations - Adding a member - I
- Custom annotations - default values - I
- Custom annotations - default values - III
- Annotating an annotation- III
- Custom annotations - Adding a member - II
- ANT Targets and Tasks
- Ant Project
- RCP Custom Look and Feel
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