ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Loughran" <stev...@iseran.com>
Subject Re: condition shortcutting
Date Tue, 15 Jan 2002 01:25:13 GMT

----- Original Message -----
From: "Magesh Umasankar" <umagesh@apache.org>
To: "Ant Developers List" <ant-dev@jakarta.apache.org>
Sent: Monday, January 14, 2002 16:59
Subject: Re: condition shortcutting


> From: "Steve Loughran" <steve_l@iseran.com>
>
> >
> > I have a change to <condition> which doesnt run any of the tests if the
> > property is already set; shortcutting the entire test.
> >
>
> Is your change something along the lines of an extra
> element to condition like <propertyset name="foo"/>
> which would evaluate to true if foo is set or
> <propertyset name="foo" value="bar"/> which will
> evaluate to true if foo is set to the value bar?

no, it is like we dont bother evaluating any conditions if the dest property
is already set, because the immutability rules imply that the condition
cannot change the value of the property anyway.

So it's about 2 lines of code in Condition.java, which is why I didnt bother
mentioning it. I will post it later, when I have it to hand, but roughly it
goes into execute as

if(project.getProperty(property)!=null) {
    //eval the condition
}

No changes to the external interface, no changes to the behavior of the
build, except that conditions dont get evaled if the test is overridden.

This can make a build faster and let you do things like

<condition "box.offline">
 <http url="http://apache.org/>
</condition>

if the box.offline property is set to true already, then the test isnt
attempted. To get the same effect you would have to do today

<condition "box.offline">
 <or>
  <isset property="box.offline"/>
  <http url="http://apache.org/>
 </or>
</condition>

If the result of any condition is not set (the default), this has no effect
whatsoever. It is only a speedup/bypass if somebody overrides a test
upfront.




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


Mime
View raw message