ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <>
Subject RE: using dynamic declarations..
Date Fri, 16 Oct 2009 13:59:24 GMT

-----Original Message-----
From: EetieD [] 
Sent: Thursday, October 15, 2009 11:32 AM
Subject: using dynamic declarations..


I was wondering if it is possible to use 'dynamic declarations' within ANT.
Please check the example below. In the line '<echo>${value.${id}}</echo>', I
would like to print a value which is dependant on the id. But for now, I
cannot use this construction, because it prints '${value.${id}}' literaly.
If possible, how can I still use this construction?  

I hope someone can help. Thanks!!


<target name="check.numberr">
	<var name="value.3" value="3" />
	<var name="value.4" value="4" />
	<var name="id" value="3" />     <!-- now it is 3, but it can also be 4 -->

	<echo>${value.${id}}</echo> <!-- how to use this? -->
	<echo>${value.3}</echo>       <!-- this works -->

a solution with AntXtras ( =

<!-- import AntXtras -->
<taskdef resource="org/jwaresoftware/antxtras/antlib.xml"/>
<!-- enable funcuts -->
<managefuncuts action="enable"/>

<target name="main">

  <assign var="value.3" value="foobar"/>
  <assign var="value.4" value="foobaz" />
  <!-- now it is 3, but it can also be 4 -->
  <assign var="id" value="3" />

  <echo>Should print 'foobar' => ${$var:value.${$var:id}}</echo>
  <echo>Should print 'foobaz' => ${$var:value.4}</echo>


will print =

     [echo] Should print 'foobar' => foobar
     [echo] Should print 'foobaz' => foobaz

Regards, Gilbert

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message