Ant - taskdef (Optional Task)

1 - About

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

3 - Prerequisites

3.1 - Adding library

Use Ant's own mechanisms for adding libraries:

  • via command line argument -lib
  • adding to ${user.home}/.ant/lib
  • adding to ${ant.home}/lib

4 - Declaration

4.1 - 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!"/>
  </target>
  
</project>

4.2 - Properties file

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


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

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

4.4 - antlib.xml

declare a bundle of tasks using a xml-file named antlib.xml, XML-namespace and antlib: protocol handler <project xmlns:ac=“antlib:net.sf.antcontrib”/> <ac:for … />

5 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap