ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim White <...@pagesmiths.com>
Subject RE: nested ${} expressions
Date Tue, 15 Jan 2002 17:43:10 GMT
At 04:20 PM 1/15/2002 +0200, Rahamim, Zvi (Zvi) wrote:
>I want that d will have the value: 'x'
>When I do this, it doesn't work:
>
>   <property name="a" value="aaa"/>
>   <property name="b" value="bbb"/>
>   <property name="c" value="${a}.${b}"/>
>   <property name="aaa.bbb" value="x"/>
>   <property name="d" value="${c}"/>

There are two basic solution approaches.  Which one to use depends on 
exactly what your application is.

If the reason for the dynamic property names is that you have a 
nested/modular build, then I suggest breaking your build.xml file into two 
parts.  The second build.xml can have filter tokens in it, which you 
replace using the filter and copy tasks (or the style task if you prefer), 
then invoke with the ant task.

If that doesn't suit the style of your build, then use the script 
task.  Just setup the scripting engine (easiest to setup is probably Rhino 
for JavaScript).  Then you can say:

   <project name="myproject" ...
    <script language="javascript"><[CDATA[
        var c = myproject.getProperty("c");
        var d = myproject.getProperty(c);
        myproject.setProperty("d", d);
    ]]></script>

http://www-124.ibm.com/developerworks/projects/bsf
http://www.mozilla.org/rhino/

jim

----------------------------------------------------------------
James P. White     Pagesmiths' home is http://www.pagesmiths.com
Live free http://www.ushistory.org/franklin/quotable/quote04.htm
Try Kawa, the Java-based Scheme http://www.gnu.org/software/kawa


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


Mime
View raw message