Ant - taskdef (Optional Task)

Card Puncher Data Processing


An optional task is a task which typically requires an external library to function.


Adding library

Use Ant's own mechanisms for adding libraries:


Single Task

<?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!"/>

Properties file

declare a bundle of tasks using a properties-file holding these taskname-ImplementationClass-pairs and <taskdef>

<taskdef resource="net/sf/antcontrib/" /> <for ... />

Xml file

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 ... /> 

Documentation / Reference

Discover More
Card Puncher Data Processing
Ant - Task

A task is a function and belongs to a target The task operates only on the parameters it is given. Tasks can consume and emit items and properties. By design, they have no other insight into the state...
Card Puncher Data Processing
How to develop a Task for Ant?

How to develop a Task for Ant A class is registered as an AnT task if it's provide a method with the signature “public void execute()”. The class doesn't need to extends no superclass and...

Share this page:
Follow us:
Task Runner