Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 33154 invoked from network); 13 Apr 2004 20:09:47 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 13 Apr 2004 20:09:47 -0000 Received: (qmail 27837 invoked by uid 500); 13 Apr 2004 20:09:26 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 27813 invoked by uid 500); 13 Apr 2004 20:09:26 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 27793 invoked from network); 13 Apr 2004 20:09:25 -0000 Received: from unknown (HELO c000.snv.cp.net) (209.228.32.83) by daedalus.apache.org with SMTP; 13 Apr 2004 20:09:25 -0000 Received: (cpmta 29475 invoked from network); 13 Apr 2004 13:09:30 -0700 Received: from 128.143.104.180 (HELO ?128.143.104.180?) by smtp.hatcher.net (209.228.32.83) with SMTP; 13 Apr 2004 13:09:30 -0700 X-Sent: 13 Apr 2004 20:09:30 GMT Mime-Version: 1.0 (Apple Message framework v613) In-Reply-To: <20040413192629.32388.qmail@web40606.mail.yahoo.com> References: <20040413192629.32388.qmail@web40606.mail.yahoo.com> Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Message-Id: <7A703420-8D86-11D8-97BB-000393A564E6@ehatchersolutions.com> Content-Transfer-Encoding: quoted-printable From: Erik Hatcher Subject: Re: Embedded Properties Date: Tue, 13 Apr 2004 16:09:32 -0400 To: "Ant Users List" X-Mailer: Apple Mail (2.613) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Apr 13, 2004, at 3:26 PM, Ivan Ivanov wrote: > Hi Nick, Stefan and all we can do this also: > id=3D"Lib.Name.Static"/> > id=3D"Lib.Name.Dynamic" /> > > > BUT, the Holy Book[1] says it is bad :)) It does? I had to go search for refid in the PDF to find what I said=20 about it. The full section is pasted below. Yeah, I suppose I did say=20= it is bad, but only because of what I thought of a better alternative=20 to property swapping. I would argue that for most cases, what folks=20 really should use is the .properties file trick shown below, but having=20= dynamically dereferenced properties is handy in some cases too. I do,=20= however, use the task from ant-contrib, and now with=20 Stefan's macrodef example, I'll likely switch to that. Erik Dereferencing properties Makefile experts, and others desiring tricky variable dereferencing may=20= be disappointed to find that Ant does not have advanced evaluation of properties. They=20= are simply string substitutions and nesting properties does not accomplish=20= what some may expect. For example The =93$$=94 is replaced by = =93$=94 The output of the above is [echo] A =3D ${${X}} [echo] B =3D ${Y} It is possible, however, to accomplish this, though rarely, if ever,=20 would this particular technique be needed in a build file. Make has a feature called=20 =93computed variable names,=94 which is similar to our first attempts at dereferencing, yet=20= with different results. (In other words, A would have equaled Z.) Using an additional=20= property is required as a selector: While this appears fairly straightforward, it is actually taking=20 advantage of some fairly complex capability of Ant, that of assigning an id to a task (in this=20 case ). The value of selector becomes Y, and the assignment of A uses the value of the referenced =93object=94 (in this case a task) by the name of = Y.prop.=20 Avoid this kind of wackiness at almost all costs because there are much more=20 standard and clearer ways to choose a different set of properties, such as In this case, we load default.properties unless the property props has=20= been overridden previously, perhaps with ant -Dprops=3Dmy This would load my.properties instead, thanks to property immutability=20= and -D setting props first. NOTE There is a third-party task provided at the=20 Sourceforge ant-contrib project that more cleanly accomplishes property=20 dereferencing. We recommend using this task instead of the craziness shown here. See section 10.6 for details on . --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org