More Java posts
August 16, 2003
A New Ant Task

I've just created a new Ant data type that I think other people may also find useful. Of course, I've probably just duplicated someone else's work but it was still fun.

It is designed to let you externalize definitions that are common across multiple build files, or even projects, into one or more reusable common files. The inspiration was IntelliJ IDEA's library facility. To do this the new type adds all of the refs from an Ant project file into the current project. An example usage is

<load_external_refs location="common_paths.xml" refidPrefix="ext."/>

This will take all of the refs defined in common_paths.xml and add them to the project that contains the load_external_tasks element, prefixing each one with ext.. For instance if common_paths.xml includes a path element defined with a ref="junit" attribute then this will appear as a ref ext.junit in the project that includes the load_external_tasks element.

Before you can use load_external_tasks you need to tell Ant about it with a typedef element.

<typedef name="load_external_refs" 
             classname="com.zanthan.ant.LoadExternalRefs">
    <classpath path="lib/zanthan_ant.jar"/>
</typedef>

The compiled code is in zanthan_ant.jar while the source, including a quick example of it's use in build.test.xml, is in zanthan_ant_src.jar

Posted by Alex at August 16, 2003 07:33 PM
Comments
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?