You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Laurie Harper <zo...@holoweb.net> on 2002/09/02 23:43:14 UTC

Maintaining dependencies across antcalls

Is there a way to use antall or something similar that maintains the
dependency graph? For example, if I have:

<project name="..." default="master">
  <target name="init">
    <echo message="init"/>
  </target>
  <target name="worker" depends="init">
    <echo message="worker: ${x}"/>
  </target>
  <target name="master" depends="init">
    <antcall target="worker"><param name="x" value="y"/></antcall>
    <antcall target="worker"><param name="x" value="z"/></antcall>
  </target>
</project>

Then running ant causes 'init' to be invoked 3 times. I only want it to be
executed once.

Thanks,

L.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Nicola Ken Barozzi <ni...@apache.org>.
Laurie Harper wrote:
> Erm, yes, that's the point. I want to be able to declare my dependencies
> (for example, so that I can expect 'ant worker' to work as well as 'ant
> master') without getting required targets executed repeatedly.

Understand, you need an inner <depends target=""/> tag.

I've almost finished it (fixing a but), and will submit it soon, stay 
tuned :-)


-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Laurie Harper <zo...@holoweb.net>.
Erm, yes, that's the point. I want to be able to declare my dependencies
(for example, so that I can expect 'ant worker' to work as well as 'ant
master') without getting required targets executed repeatedly.

L.

On 9/2/02 5:49 PM, "Nicola Ken Barozzi" <ni...@apache.org> wrote:

> 
> 
> Laurie Harper wrote:
>> Is there a way to use antall or something similar that maintains the
>> dependency graph? For example, if I have:
>> 
>> <project name="..." default="master">
>>   <target name="init">
>>     <echo message="init"/>
>>   </target>
>>   <target name="worker" depends="init">
>                          ^^^^^^^^^^^^^^^^^
>   <target name="worker">
> 
>>     <echo message="worker: ${x}"/>
>>   </target>
>>   <target name="master" depends="init">
>>     <antcall target="worker"><param name="x" value="y"/></antcall>
>>     <antcall target="worker"><param name="x" value="z"/></antcall>
>>   </target>
>> </project>
>> 
>> Then running ant causes 'init' to be invoked 3 times. I only want it to be
>> executed once.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Nicola Ken Barozzi <ni...@apache.org>.

Laurie Harper wrote:
> Is there a way to use antall or something similar that maintains the
> dependency graph? For example, if I have:
> 
> <project name="..." default="master">
>   <target name="init">
>     <echo message="init"/>
>   </target>
>   <target name="worker" depends="init">
                           ^^^^^^^^^^^^^^^^^
    <target name="worker">

>     <echo message="worker: ${x}"/>
>   </target>
>   <target name="master" depends="init">
>     <antcall target="worker"><param name="x" value="y"/></antcall>
>     <antcall target="worker"><param name="x" value="z"/></antcall>
>   </target>
> </project>
> 
> Then running ant causes 'init' to be invoked 3 times. I only want it to be
> executed once.
-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Nicola Ken Barozzi <ni...@apache.org>.
Laurie Harper wrote:
> On 9/4/02 8:48 AM, "Stefan Bodewig" <bo...@apache.org> wrote:
> 
>>Set the property inside master after the first <antcall> or for each
>><antcall> as a <param>.  Neither is pretty.
> 
> 
> Hmm; it would also be a maintenance nightmare in my real build file!
> 
> I'll look at how target execution works for antcall and for depends and see
> if I can work up a patch that would give me the functionality I want. I
> think that's 'call another task in the context of this project rather than
> an independent project' which doesn't sound like it should be too hard...

I've sent a patch to Bugzilla that should do this.
See if it can work for you.

[PATCH] enable <depends target=""/> tag inside targets

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12292

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Laurie Harper <zo...@holoweb.net>.
On 9/4/02 8:48 AM, "Stefan Bodewig" <bo...@apache.org> wrote:
> Set the property inside master after the first <antcall> or for each
> <antcall> as a <param>.  Neither is pretty.

Hmm; it would also be a maintenance nightmare in my real build file!

I'll look at how target execution works for antcall and for depends and see
if I can work up a patch that would give me the functionality I want. I
think that's 'call another task in the context of this project rather than
an independent project' which doesn't sound like it should be too hard...

Thanks,

L.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 03 Sep 2002, Laurie Harper <zo...@holoweb.net> wrote:

> It breaks again if 'master' doesn't depend on 'init' because then
> the init-complete property is only set for the scope of one
> 'antcall'.

True.

> Any other suggestions?

Set the property inside master after the first <antcall> or for each
<antcall> as a <param>.  Neither is pretty.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Laurie Harper <zo...@holoweb.net>.
Ugh. OK, it almost works. It breaks again if 'master' doesn't depend on
'init' because then the init-complete property is only set for the scope of
one 'antcall'.

Any other suggestions?

L.

On 9/3/02 11:04 AM, "Laurie Harper" <zo...@holoweb.net> wrote:

> Thanks, Stefan, that did the trick!
> 
> L.
> 
> On 9/3/02 2:22 AM, "Stefan Bodewig" <bo...@apache.org> wrote:
> 
>> On Mon, 02 Sep 2002, Laurie Harper <zo...@holoweb.net> wrote:
>> 
>>>   <target name="init">
>>>   <target name="worker" depends="init">
>>>   <target name="master" depends="init">
>>>     <antcall target="worker"><param name="x" value="y"/></antcall>
>>> 
>>> Then running ant causes 'init' to be invoked 3 times. I only want it
>>> to be executed once.
>> 
>> Guard against it with a property.
>> 
>> <target name="init" unless="init-complete">
>> ...
>> <property name="init-complete" value="who cares?"/>
>> </target>
>> 
>> Stefan
>> 
>> --
>> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>> For additional commands, e-mail: <ma...@jakarta.apache.org>
>> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Laurie Harper <zo...@holoweb.net>.
Thanks, Stefan, that did the trick!

L.

On 9/3/02 2:22 AM, "Stefan Bodewig" <bo...@apache.org> wrote:

> On Mon, 02 Sep 2002, Laurie Harper <zo...@holoweb.net> wrote:
> 
>>   <target name="init">
>>   <target name="worker" depends="init">
>>   <target name="master" depends="init">
>>     <antcall target="worker"><param name="x" value="y"/></antcall>
>> 
>> Then running ant causes 'init' to be invoked 3 times. I only want it
>> to be executed once.
> 
> Guard against it with a property.
> 
> <target name="init" unless="init-complete">
> ...
> <property name="init-complete" value="who cares?"/>
> </target>
> 
> Stefan
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Maintaining dependencies across antcalls

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 02 Sep 2002, Laurie Harper <zo...@holoweb.net> wrote:

>   <target name="init">
>   <target name="worker" depends="init">
>   <target name="master" depends="init">
>     <antcall target="worker"><param name="x" value="y"/></antcall>
> 
> Then running ant causes 'init' to be invoked 3 times. I only want it
> to be executed once.

Guard against it with a property.

<target name="init" unless="init-complete">
  ...
  <property name="init-complete" value="who cares?"/>
</target>

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>