How-To Guides
Getting Started
Policy Strategies
Format Strings
Extending Antlion
First Tutorial: Simple
Ant Tasks
inner processors
inner repositories
Optional Tasks
About optional tasks
Prev   Next  
Extending Antlion

Antlion attempts to keep itself open to user extensions. The antlion-optional jar is one example of that. Since most of the exention points of Antlion are described elsewhere, this document will just point to where you can look for details.

Adding Customizations Into Ant

One big caveat to adding custom extensions to Antlion into Ant is the classpath. If you're putting all the Antlion libraries into the Ant lib directory, then you have nothing to worry about. Just add the tasks as you normally would through Ant <taskdef> tasks, and skip the rest of this section.

However, if you put Antlion in its own classpath, then there are some hurdles to tackle. To be rather technical, extensions must either be in the same classloader or a child classloader to the ones containing Antlion. This means that, to load Antlion jars outside of the Ant library, you need to do something like the following:

<path id="lib.antlion">
  <pathelement location="${lib.dir}/antlion-inline-0.9.0.jar" />
  <pathelement location="${lib.dir}/extended-antlion.jar" />

<taskdef resource="net/sf/antlion/antlib.xml"
    loaderref="lib.antlion.loader" />
<taskdef name="my-extension-task"
    loaderref="lib.antlion.loader" />

There are some alternatives available. For instance, you can join these <taskdef> declarations into a single statement, and use a custom antlib.xml resource:

    <typedef resource="" />
    <taskdef resource="" />
    <taskdef resource="" />

In the case of a custom token formatter, the options are the same. When loading the formatter directly from ant, the taskdef would look something like:

<typedef name=".antlion.token-formatter-factor"
    loaderref="lib.antlion.loader" />
whereas in the custom antlib.xml could load the taskdef using only the name and classname attributes.


You can find out more about adding new repositories in the policies page.


With processors, you can either add a custom processor through the scripting processor, or create your own Java-based processor.


You can add your own custom formatted string evaluation method through the process described here.

URL Download Validation

When dealing with the <library-urlrepository>, you can use a custom file validation class. The custom class needs to be registered like a standard Ant data type under Antlion:

<typedef name="my-custom-validator"
    loaderref="lib.antlion.loader" />
<urlrepository ...>
    <my-custom-validator />
Custom validators must implement Antlion comes with an MD5 checksum validation method, which shows how a validator can download an additional file to perform the check (

This can be useful if the site you're downloading from doesn't generate errors when a resource isn't found. In this scenario, you can have your validator check if the top bytes of the downloaded file contain a "File not found" kind of message.

Prev   Next  
Document version $Revision: 1.3 $ $Date: 2005/12/21 16:50:38 $

SourceForge Logo
Copyright © 2004-2006, The Antlion Project