ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Wall <>
Subject Re: Conditional target execution based on prerequisite execution
Date Tue, 18 Feb 2003 16:36:00 GMT
 From Using Ant->Targets:

> A target can depend on other targets. You might have a target for 
> compiling, for example, and a target for creating a distributable. You 
> can only build a distributable when you have compiled first, so the 
> distribute target depends on the compile target. Ant resolves these 
> dependencies.
> It should be noted, however, that Ant's depends attribute only 
> specifies the order in which targets should be executed - it does not 
> affect whether the target that specifies the dependency(s) gets 
> executed if the dependent target(s) did not (need to) run.

This raises the question (for me): What *does* affect whether the 
target that specifies the dependency(s) gets executed if the dependent 
target(s) did not (need to) run?  Of course, that paragraph may not 
mean anything at all...

If B is only run when one or more of its dependencies is run, then the 
problem seems to be those bootstrap targets which have no "depends"; 
they need to be conditionally run to prevent the entire remainder of 
the chain from always being run.

What is the canonical "Only create this directory if it doesn't exist" 

On Tuesday, February 18, 2003, at 11:05 AM, Mike Ayers wrote:

>> From: Timothy Wall []
>> Sent: Tuesday, February 18, 2003 7:04 AM
>> I would expect something like
>> <target name="A"/>
>> <target name="B" depends="A" onlyif="A-was-run"/>
> 	If target B depends only on target A, then target B will be run only 
> if target A was run, and your "onlyif" clause is moot.
> 	In other words:
> <target name="A" depends=target.A.dependencies />
> <target name="B" depends="A" />
> 	is precisely equivalent to:
> 	A: $target_A_dependencies
> 	B: A
> a Makefile.  Note that this works only if B has only A as a 
> dependency, just like in make, and that therefore you could just merge 
> the two targets, just like in make.
>> I'm assuming it's not, since the "depends" documentation explicitly
>> states that it has absolutely no effect on whether or not a
>> target gets
>> run, and provides no links to any facility which might have such an
>> effect.
> 	Huh?  Where did you read that?  The "Targets" subsection of "Using 
> Ant" in the manual (, can't link the page 
> because it's done in frames :-p ) says no such thing, as far as I can 
> tell.  I think maybe you misread the second paragraph, which can be 
> confusing.

View raw message