ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron McCormack <>
Subject Re: Using antcall but not re-running dependent targets
Date Sun, 21 Jan 2007 04:17:58 GMT
Hi Ninju.

Ninju Bohra:
> The behavior you see is correct...there is an inherent limition of the
> <antcall> task becuase it starts a new ANT "cycle" and knowlegde of
> previous run targets (like your "init" target) are not retained.
> You can try many different solutions: 
> First solution: 
> 1) Create a "property setting" target like the following 
> <target name="determineOS">
>     <condition property="isMAC">
>         <os name="Mac OS X"/>
>     </condition>
> </target>
>       The key thing is to avoid the usage of the else attribute of the
> condition task, we DO NOT want the property to be defined only IF the
> OS is Mac OS X
> 2) Now add an "if" to your "two-mac" target --> so that it will only execute if the
isMAC property is set
>     <target name="two-mac" if="isMAC" depends="init">
>         .
>         .
>         .
>     </target>
>         Now unfortunately, the way ANT is written the presence of an
> "if" attribute only controls the execution of the tasks within the
> target NOT the execution of the dependent targets (but we will fix
> soon enough)

Yes that is the problem I ran into when structuring my targets with
'if's, and switched to using antcalls.  The ability to have dependent
targets not executed if the target is not to be executed would be a
welcome addition.

> 6) Along the same line, to make sure that the code of the "init"
>target is run only once you can add an "unless" attribute in its
>definition and set the property at the bottom of the target:
>     <target name="init" unless="init_run_already">
>         .
>         (really delicate stuff that can only be run once)
>         .
>         <property name="init_run_already" value="yeah!!!"/>
>     </target>

Ah that’s a good workaround.



Cameron McCormack,  ▪  ICQ 26955922  ▪  MSN

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message