ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
Subject Re: failonerror for target and depends
Date Fri, 24 Jul 2009 02:35:36 GMT
> I understand how depends works but my question is..
>
> If I have two targets defined in depends for e.g  
> depends="target1,target2",
> and if some how target1 does not exist and instead of throwing error  
> ant
> should move ahead (after showing some warning) and execute target2.


If you don't depend upon target1, then why are you putting it in a  
depends parameter? The depends parameter says that this target can't  
be executed unless the dependancy targets are first built.

Target1 and target2 both must exist. Otherwise, Ant can't build a  
dependancy matrix.

You're also making assumption about execution order (Ant will try  
target1, then target2.) Nothing in ant specifies whether one target is  
executed before another. Ant figures out the order after it builds the  
dependancy matrix.

In fact:

<target name="one" depends="two"/>
<target name="two"/>
<target name="three"
     depends="one,two"/>

If I execute target "three", target "two" will be built before target  
"one" even though I listed target "one" first in the "depends"  
parameter.

I'm not sure what you're attempting, but if you need to test before  
you execute, you can use the <condition> task, or you can try the  
AntContrib's <try>/<catch> task: http://ant-contrib.sourceforge.net/tasks/tasks/index.html

.

You could put an <antcall> in the <try> block, and if it can't find  
the target, go to the <catch> block where you'll simply echo that the  
task can't be found. From there, your program will continue executing.

--
David Weintraub
David@Weintraub.name
Sent from my iPhone while riding in my Ferrari. (Jealous?)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message