|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
using dynamic declarations..Hi,
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 use this construction anyways? I hope someone can help. Thanks!! EetieD <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 --> </target> |
|
|
AW: using dynamic declarations..Maybe use propertycopy from antcontrib package.
Juergen -- Jürgen Knuplesch -----Ursprüngliche Nachricht----- Von: EetieD [mailto:khn@...] Gesendet: Donnerstag, 15. Oktober 2009 11:32 An: user@... Betreff: using dynamic declarations.. Hi, 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!! EetieD <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 --> </target> -- View this message in context: http://www.nabble.com/using-dynamic-declarations..-tp25905565p25905565.html Sent from the Ant - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: using dynamic declarations..On 2009-10-15, EetieD <khn@...> wrote:
> 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. Not in Ant 1.7.1 or earlier, except using some tricks <http://ant.apache.org/faq.html#propertyvalue-as-name-for-property> Once it they are ready Ant 1.8.0 and the new props Antlib will provide a simpler way to do just that. Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
RE: using dynamic declarations..-----Original Message----- From: EetieD [mailto:khn@...] Sent: Thursday, October 15, 2009 11:32 AM To: user@... Subject: using dynamic declarations.. /* Hi, 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!! EetieD <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 --> </target> */ a solution with AntXtras (http://jwaresoftware.org/wiki/antxtras/home) = <!-- 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> </target> will print = main: [echo] Should print 'foobar' => foobar [echo] Should print 'foobaz' => foobaz BUILD SUCCESSFUL Regards, Gilbert --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: AW: using dynamic declarations..Thanks for all the replies!
(I used propertycopy, which it works perfect for me.)
|
|
|
Re: using dynamic declarations..You can do this in Ant 1.7.1 without any extensions:
<property id="value.3" value="3"/> <property id="value.4" value="4"/> <property name="id" value="3"/> <property name="value.id" refid="value.${id}"/> <echo>${value.id}</echo> I use this to set up builds for different platforms. For example, <property id="cc.flags.arm" value="..."/> <property id="cc.flags.x86" value="..."/> <property id="cc.flags.mips" value="..."/> <property name="cc.flags" refid="cc.flags.${arch}"/> Daniel EetieD wrote: > Hi, > > 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!! > > EetieD > > > <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 --> > </target> > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free embeddable forum powered by Nabble | Forum Help |