ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject if/unless Attributes
Date Thu, 24 Sep 2009 11:32:20 GMT
Hi,

the if/unless attributes for target have changes slightly in that they
now may use PropertyHelpers.  I.e.

<target if="${foo}">

will not be executed if ${foo} happens to expand to a Boolean instance
with a booleanValue() of "false" and likewise

<target unless="${foo}">

will be executed in that case.  So far this hasn't been documented, but
I'll do so shortly.

Some other places where we use if/unless like the <fail> task haven't
been changed and I think it would be good to make all places consistent.

Unfortunately I don't see an easy way to do that since the Strings sent
to the attributes of tasks and types are property expanded (unlike the
attributes of target) and in the case I've described the tasks won't see
${foo} anymore but the String "false" (via the implicit Object => String
conversion of PropertyHelper)

If we changed the setters to accept an Object arg this might work - but
see the comment in Property.java:

    /* the following method is first in source so IH will pick it up first:
     * Hopefully we'll never get any classes compiled by wise-guy compilers that behave otherwise...
     */

Do we want to rely on this?

And a related question: we currently don't provide any PropertyEvaluator
that would create Booleans.  Do we want to provide something like
${isTrue:foo} that created Boolean.TRUE if Project.toBoolean(${foo}) was
true?  Or should something like this go into the props Antlib?

Stefan

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


Mime
View raw message