ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <co...@cortexebusiness.com.au>
Subject Re: variables instead properties!
Date Tue, 28 Aug 2001 11:43:02 GMT
From: "Edgar Sánchez" <vesanchez@yahoo.com>
To: <ant-user@jakarta.apache.org>
Sent: Tuesday, August 28, 2001 2:04 AM
Subject: RE: variables instead properties!


> Daisy thanks,
>   But, let me see if I undestood...
>
>   if a declare a property inside a target, when the
> target finish is the property destroyed?? so, thats
> why i can use it again.

No. It means that the property will only be set if that target is executed.
Once set, the property can't be changed. So, whichever target is evaluated
first will "win" and get to set the property value.

OK, so why are properties immutable (note this has been discussed more
times than I can remember)? Well an Ant build file is not a program and
sometimes you need to think a little bit differently. In a build, you
occasionally need to control the build from "outside", where outside can
either be the command line or a parent build calling a subbuild. When
running a build and you want to change the destination directory, you don't
want to have the build file. So immutability of properties moves control
from the build file writer to the build file user.

If you need a property to have different values in the same build file, the
usual solution is to use an <antcall> to control the scope the property
values. Have a look at ant's own build file for an example of <antcall> in
action. However, before you jump in and obfuscate your build by adding a
whole lot of <antcall>s, I'd encourage you to think about whether it can be
done without it. Most of our build files for building EJB servers neither
use <antcall> nor need to redefine property values. The "Keep it simple"
principle goes a long way :-)

Conor





Mime
View raw message