Ant is not a programming language! Ant is not a programming language! Repeat
that.

Ant build system. And yes, there is a major difference. In a programming
language, you set the exact order you want everything executed in. In a
build system, the build system builds a dependency matrix and then decides
on the order tp execute the various tasks in.

When you execute Ant, the very first thing it does is look for all the
targets in your build.xml file, and then builds a dependency matrix based
upon each target's "depends" statement. It doesn't even look at the contents
of the target or  the "if" and "unless" statements.

Your issue is that you're treating the "if" and "unless" statements as if it
was part of a programming language. Normally, the "if" and "unless"
statements are used to prevent a target from executing because the
conditions for that target aren't met, and this condition is normally set in
a previous target. I do this type of stuff all the time:

<target name="mytarget.test">
     <condition property="mytarget.is.setup">
         <blah, blah, blah>
     </condition>
</target>

<target name="mytarget" depends="mytarget.test"
     if="mytarget.is.setup">
     <blah, blah, blah/>
</target>

In the above, I want to execute "mytarget" but I want to make sure
everything is actually setup to execute this target. So, I have a
"mytarget.test" target I depend upon. This sets a property letting me know
if everything is all setup or not.

I hope this explains why Ant is doing what it is doing and why your
build.xml isn't quite doing what you expect.. It looks like (and what you
did) was add the "nocoverage" if check to the other target. That's one way
to handle this issue.

On Mon, Aug 31, 2009 at 4:53 AM, Francis GALIEGUE<f...@one2team.com> wrote:
> Hello everyone,
>
> I have noticed something strange in the if="" and unless="" attributes
> of targets.
>
> Let's say that I have:
>
> <target name="t1"/>
>
> <target name="t2" unless="p2"/>
>
> <target name="t" unless="p" depends="t1, t2"/>
>
> If I:
>
> ant -Dp2=1
>
> then, as expected, t1 triggers via t but not t2.
>
> However, if I:
>
> ant -Dp=1
>
> I'd have expected none of t1 and t2 to execute, but both are executed!
>
> Which means that the dependencies of a target are executed before even
> any if="" or unless="" attributes are taken into account... This is
> rather counterintuitive to my eyes. Is this really the expected
> behaviour or is this a bug?
>
>
> --
>
> Francis Galiegue
> ONE2TEAM
> Ingénieur système
> Mob : +33 (0) 683 877 875
> Tel : +33 (0) 178 945 552
> f...@one2team.com
> 40 avenue Raymond Poincaré
> 75116 Paris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
> For additional commands, e-mail: user-h...@ant.apache.org
>
>



-- 
David Weintraub
qazw...@gmail.com

Reply via email to