You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Eric Wood <EW...@llbean.com> on 2008/08/22 17:03:01 UTC

target conditional and dependency issue

I have a target that I only want to execute if a property is set, but it
executes the dependencies regardless.  
The code looks like this:
 
    <target name="cruisecleanup" depends="init, clean, prepare,
_cruisecleanup" if="cruise.logs.dir" />
 
What I have used as a work around is:
 
    <target name="cruisecleanup" depends="" if="cruise.logs.dir" />
       <runtarget target="run-cruisecleanup">
    </target>
 
    <target name="run-cruisecleanup" depends="init, clean, prepare,
_cruisecleanup" />
 
This works, but it doesn't seem very ANT like.  Do folks have a better,
way to perform the conditional execution with a dependency list?
 
Thanks, Eric
 

Re: target conditional and dependency issue

Posted by David Weintraub <qa...@gmail.com>.
On Fri, Aug 22, 2008 at 11:03 AM, Eric Wood <EW...@llbean.com> wrote:
> I have a target that I only want to execute if a property is set, but it
> executes the dependencies regardless.

Yes, the dependencies to get hit before the test is done. There's a
reason for that:


<target name="foo"
    depends "foo-test"
    if='foo-test-passes"/>

<target name="foo-test">
<condition property="foo-test-passes"
     <some condition>
</condition>

This allows me to run my target "foo", but only if I pass the
"foo-test". Otherwise, there would be no easy way to run a target
based upon a more complex condition than whether a particular property
is set or not.

Your work around is pretty much the way to make sure that you don't
run dependencies if the target is not suppose to be executed.

--
David Weintraub
qazwart@gmail.com

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