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.
|
Showing messages 1 through 3 of 3.
-
Feedback
2004-06-05 22:21:11
Michael Fitzgerald | 
[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]
(2) Ant is a nice tool, but I don't feel it is necessary to use it to build something as simple as Add.java -- one very small class with almost zero potential for continuous debugging or rebuilding.
(3) As far as using .class files: How exactly do you do that? I tried it every which way from Tuesday with no luck. Show us! (I haven't paid any attention to Antlib yet. Thanks for pointing it out.)