rogah / ant-task

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Template for Custom ANT Task

This is template for start writing a ANT custom task. The build.xml includes the following:

  1. Basic structure for ANT project:
  2. Set the build number;
  3. Import build.properties file;
  4. Set environment variable;
  5. Set timestamp;
  6. Set default task;
  7. Compile java;
  8. Create JAR file:
  9. Copy the antlib.xml files to bin folder with .class files;
  10. Create manifest file manifest.mf;
  11. Create the JAR file into build folder (including lib files);
  12. Deploy the JAR file to %ANT_HOME%\lib directory;
  13. Cleanup files;

Antlib

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.

About


Languages

Language:Java 100.0%