ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@eng.sun.com
Subject Re: Subtasks within tasks
Date Fri, 25 Feb 2000 01:40:17 GMT
I have few problems with that particular solution:

- it is specific to Tasks ( createSubTask, SubTaskable, etc ) - everything
else in ant is using introspection and patterns.

- it sound a bit to complex 

- What is a sub task anyway ? I can't figure what it will do. SubCopy? 

If you have a particular task that needs this kind of sub-task we should
try to find a pattern-based solution.

In particular addXXX works fine in this case and doesn't require any
interface ( and it's implemented in tomcat ):

For "<foo>":

- first try createFoo() 
- if no such method is found, try to create a foo object ( based on 
existing taskdefs )
- try addFoo( foo ) 
- if no such method try addBar() where Bar is an interface implemented by
foo ( or superclass).

Each "try" is just a getMethod() and check if not null, and it's very
easy. I think the pattern makes sense and in tomcat seems to work fine
( addServerConnector() with AjpConnector, HttpConnector, etc ).

Costin

 


>   The current ANT allows you to have properties within tasks, and these can
> be arbitrarily nested, but each one requires a createXxxx() method to
> return an object that goes along with that XML property.  This means you
> can't have general sub-Tasks.  You'd have to make a createXxxx() method for
> each task - not feasable.
> 
>   So, I've implemented some changes that allow arbirary sub-Tasks.  There
> is a new interface: SubTaskable which has an addSubTask(Task) method.  When
> a property is encountered for which there is no createXxxx() method, the
> element is checked to see if it implements SubTaskable.  If it does then a
> task with the appropriate name is created and added using the
> addSubTask(Task) method.




> 
>   To keep things clean I also modified Target and Task slightly.  Target
> now implements SubTaskable.  The Task.setTarget(Target) has been changed to
> Task.setTarget(SubTaskable).  I also deprecated the Target.addTask(Task)
> method.  It does the same thing as the new addSubTask(Task) method.  I
> didn't use addTask(Task) in the SubTaskable interface because that might
> conflict with an attribute.  With it's two capitals, addSubTask() cannot.
> 
>   I've attached diffs for ProjectHelper.java, Task.java and Target.java.
> I've attached the complete SubTaskable.java.  I've also attached a task,
> SubTaskTest.java, that simply executes each of its subtasks in order.
> 
> later,
> 
> \x/ill       :-}
> 




Mime
View raw message