This is template for start writing a ANT custom task. The build.xml
includes the following:
- Basic structure for ANT project:
- Set the build number;
- Import
build.properties
file; - Set environment variable;
- Set timestamp;
- Set default task;
- Compile java;
- Create JAR file:
- Copy the
antlib.xml
files to bin folder with .class files; - Create manifest file
manifest.mf
; - Create the JAR file into build folder (including lib files);
- Deploy the JAR file to
%ANT_HOME%\lib
directory; - Cleanup files;
An antlib file is an xml file with a root element of "antlib".
<?xml version="1.0"?>
<antlib>
<taskdef name="foobar" classname="com.foo.bar.FooBarTask" />
</antlib>
Which allows you to reference your ANT lib through a namespace (e.g. xmlns:my="antlib:com.foo.bar") as follows:
<project name="Custom ANT Task Demo"
basedir="."
default="default"
xmlns:my="antlib:com.foo.bar">
...
<target name="default">
<my:foobar message="baz qux!" />
</target>
...
</project>
More on Antlib URL address.