ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Writing Ant Tasks
Subject:   Feedback
Date:   2004-06-04 02:05:08
From:   erikhatcher
A couple of comments - in your first example, you do not even need to extend Task or import BuildException - you never throw it or use the Task infrastracture. Simply a "public void execute()" method makes a class an Ant task.


I find it comical that you used javac and jar at the command-line to build your Ant task JAR. You should have used Ant's javac and jar and shown how to build and use the custom task all in one shot. Interestingly, with the new scriptdef task you could have made your adder task purely as script (JavaScript for example).


And yes, you can use an Ant task as .class not in a JAR. Use the classpath capability of taskdef to set it. An even slicker method of defining tasks is through the new Antlib capability which avoids having fully qualified classnames in your build file which are subject to change.


1 to 1 of 1
  1. Michael Fitzgerald photo Feedback
    2004-06-05 22:21:11  Michael Fitzgerald | O'Reilly AuthorO'Reilly Blogger [View]

    • using classpath vs jar
      2004-07-21 20:07:48  hapybrian [View]

      • using classpath vs jar
        2004-11-23 21:22:00  Xapp [View]

1 to 1 of 1