Antlion
Welcome
License
 
How-To Guides
Getting Started
Libraries
Artifacts
Subprojects
Repositories
Policy Strategies
Format Strings
Extending Antlion
FAQ
 
Tutorials
First Tutorial: Simple
 
Ant Tasks
<artifact>
<libraryDef>
<library>
<library-policy>
inner processors
inner repositories
<library-type>
<library-repository>
<library-urlrepository>
<library-mavenrepository>
<library-repositoryset>
<create-artifact>
<subprojects>
<run-subproject>
<replace-target>
 
Optional Tasks
About optional tasks
RegexpTokenFormatter
 
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" />
</path>

<taskdef resource="net/sf/antlion/antlib.xml"
    classpathref="lib.antlion"
    loaderref="lib.antlion.loader" />
<taskdef name="my-extension-task"
    classname="my.CustomTask"
    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:

<antlib>
    <typedef resource="antlion-libraries-types.properties" />
    <taskdef resource="antlion-libraries.properties" />
    <taskdef resource="antlion-extentions.properties" />
</antlib>

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"
    classname="org.acme.formatter.CustomTokenFormatterFactory"
    loaderref="lib.antlion.loader" />
whereas in the custom antlib.xml could load the taskdef using only the name and classname attributes.


Repositories

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


Processors

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


Formatters

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"
    classname="my.CustomFileValidator"
    loaderref="lib.antlion.loader" />
:
<urlrepository ...>
    <my-custom-validator />
</urlrepository>
Custom validators must implement net.sf.antlion.utils.v1.download.FileValidator. Antlion comes with an MD5 checksum validation method, which shows how a validator can download an additional file to perform the check (net.sf.antlion.utils.v1.download.MD5FileValidator).

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