On Saturday 23 March 2002 16:59, Erik Hatcher wrote:
> There is not a whole lot of code in ExecTask. What exactly are you trying
> to re-use? There is nothing preventing you from saying:
>
> ExecTask execTask = project.createTask("exec");
> execTask.set<whatever>, etc.
> execTask.execute()
For example, for efficiency i'd like to use runExecute(), so i can set up one
Execute object and re-use it, instead of going through the whole Execute
creation/setup environment, etc., on each loop. i can't with ExecTask because
runExecute() is protected.
> I just don't (personally) like the idea of creating tasks as nested members
> all that much - just "feels" odd to me for some reason.
But the whole point of objects is re-use, not copy/paste. i can understand
why you think tasks shouldn't be nested, and i would never consider
subclassing (for example) a core task from an optional task. But if all
involved tasks are core it shouldn't be a problem. In fact re-using them
would be following one of the points from the Ant development guidelines:
don't re-invent the wheel.
After all, protected methods are, by definition, made for subclassing, so
there is no use whatsoever in providing protected methods if the class is not
intended to be subclassed. Certainly the class designer expected that the
protected functions would be useful to subclasses.
Another argument for subclassing AbstractCvsTask is that the Cvs task is a
front-end for running an external program (i.e., it's a more specific case of
ExecTask). i can't think of anything the AbstractCvsTask can do that you
can't also do with ExecTask, and that (to me) says "subclass it!"
> So, what precisely is the bottleneck in what you're attempting?
Mainly protected functions. i'll give it a try using the approach you suggest
above, though. It should work okay, i was just hoping to be a bit more
efficient with this implementation than i was in AbstractCvsTask, where
exectute() does it's whole work over and over (though 90% of it's work could
be done once and re-used, i think, since it's mainly just preparing the
environment for the actual execution).
On a related, but separate, note:
The "developing with ant" section in the docs says:
-------------
For each nested element, write a create or add method. A create method must
be a public method that takes no arguments and returns an Object type. The
name of the create method must begin with create, followed by the element
name. An add method must be a public void method that takes a single argument
of an Object type with a no-argument constructor. The name of the add method
must begin with add, followed by the element name.
-------------
Can someone tell me what the technical difference is between addXXX() and
createXXX()? i was thinking that you "add" command-line args to an ExecTask,
but it has no addXXX() (it has only createXXX()).
See ya!
----- [EMAIL PROTECTED]
http://qub.sourceforge.net - http://radioaqtiph.sourceforge.net
http://www.countermoves.net - http://stephan.rootonfire.org
"All them women gonna make me teach 'em what they don't know how.
I'm going to Jackson." -- Johnny Cash
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>