ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <>
Subject RE: global properties
Date Thu, 20 Sep 2001 23:54:08 GMT
> From: Craig Longman []
> Sent: Friday, 21 September 2001 2:13 AM
> To:
> Subject: Re: global properties
> On Thu, 2001-09-20 at 07:54, Conor MacNeill wrote:
> > Why not just do without the antcall's altogether - something like this,
> > perhaps
> i had considered doing almost exactly this, and aside from the desire to
> not use the depends in such a way,

That is exactly what "depends" is for.

it was appearing that the antcall was
> just not going to be up to snuff.  my main concern was that you have no
> direct control over the ORDER of the depends.

You have complete control. You just need to structure your dependcies to
control what gets done and when.

in this example, the
> default2 assumes the responsibility of the 'init' target, and absolutely
> has to be run before the other targets.


> so, i was doing it this way but it was not appearing to work.  so, i
> tried your suggestion, although i couldn't see any difference.  and
> guess what?  the <fail.../> is never called!  it almost seems like the
> decision to run or not run a target is made before any one of the
> depends is executed.

OK, I'm getting a better idea of what you are trying to do now. In general I
try to avoid <antcall> because it can lead to spaghetti build files, which
look like programs rather than simple build structures. It does have its
uses, though. In your example, the check target needs to be run in a
separate context so that it is run more than once - so antcall is
appropriate, but just for the check. Try this version

<project name="test" default="default2">

<target name="default1">
         <property name="use.target1" value="true"/>
         <property name="use.target2" value="true"/>

<target name="default2" depends="default1, target1, target2">
         <echo message="${prop2}"/>

<target name="target1" if="use.target1">
         <antcall target="check"/>
         <property name="prop1" value="test1a"/>
         <property name="prop2" value="test2a"/>

<target name="target2" if="use.target2">
         <antcall target="check"/>
         <property name="prop1" value="test1b"/>
         <property name="prop2" value="test2b"/>

<target name="check" if="prop1">
         <fail message="prop1 already set"/>


View raw message