ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Wright" <t...@uk.another.com>
Subject RE: Depenency Graph
Date Tue, 17 Oct 2000 13:09:40 GMT
Thanks for the prompt reply...

> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@bost.de]
> Sent: 17 October 2000 13:24
> To: ant-dev@jakarta.apache.org
> Subject: Re: Depenency Graph
>
>
> Hi Tim,
>
> >>>>> "TW" == Tim Wright <timw@uk.another.com> writes:
>
>  TW> I found that when I used this structure the order of execute of
>  TW> methods for a task was as follows:
>
> what you describe has been the order before Ant 1.2alpha3. In Ant 1.2
> it is going to be
>
> A - Component.init()
> B - Component.createDependency()
> C - Component.createDependency()
> D - Component.setName()
> E - Component$Depencency.setName()
> F - Component$Depencency.setName()
> G - Component.execute()
>
> which might be even less desirable in your case.

This order may be better... I would place my code in the execute method.

>
> A-C will be executed at parser time while D-G happens at runtime -
> this is a side effect of making properties dynamic and therefore
> delaying ${} expansion.
>
> init() is there to give the task a chance to initialize itself after
> the project and the containing target have been set. Actually <ant>
> needs init to be called before any createProperty call - this is the
> only reason why init hasn't been dropped completely.
>
> Given your preferred order, what would you want to do in init that you
> couldn't do in execute?

The problem is that I want to set some properties. Properties need to be set
in the init() method, otherwise they can't be expanded, since property
expansion is done by the time the execute() method is called. If you
concider the following tasks:

 ...
 <task_a attribute="x"/>    Here we assume task_a sets a property call
'some_property'
 <task_b attribute="${some_property}"/>
 ...

My understanding is that the new execution plan would have to be:

  ...
  Task_A.init()
  Task_B.init()
  ...
  Task_A.setAttribute()
  Task_A.execute()          - This method sets 'some_property'
  Task_B.setAttribute()     - 'some_property' is expanded by ant before
making this call
  Task_B.execute()
  ...

since the following scheme would not work.

  Task_A.init()
  Task_A.init()
  ...
  Task_A.setAttribute()
  Task_B.setAttribute()     - 'some_property' has not been set since the
Task_A.execute() has not been called.
  ...
  Task_A.execute()          - This method sets 'some_property'
  Task_B.execute()
  ...

Cheers
Tim


Mime
View raw message