You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Stefano Nichele <st...@gmail.com> on 2008/07/22 09:37:18 UTC

properties that start with ${..

Hi all,
I have a property with name ${car}. Note that the name is  not just 
"car"  but ${car}.

Using echoproperties I see:
[echoproperties] ant.version=Apache Ant version 1.6.5 compiled on June 2 
2005
[echoproperties] ${car}=fiat

How to handle that property ? How to do something like:

<echo message="My car: ${car}" />

since that one doesn't work. Conceptually it should be <echo message="My 
car: ${${car}}" /> but it doesn't work.

Thanks a lot
ste

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


Re: properties that start with ${..

Posted by Stefano Nichele <st...@gmail.com>.
By now I did a bsh method

void copyProperty(String src, String dest) {
    String srcValue = project.getProperty(src);
    project.setProperty(dest, srcValue);
}

and I call it with copyProperty("${car}", "car") so that I'm now able at 
least to access  to the value.

ste

Matt Benson wrote:
> --- Matt Benson <gu...@yahoo.com> wrote:
>
>   
>> You're in luck.  Maybe.  I tested the following:
>>
>>   <property name="$${foo}" value="foo" />
>>   <echo>${${foo}}</echo>
>>
>> and sure enough, it doesn't work.  This is not so
>> much
>> because it's no doable as it is because Ant's
>> property
>> parsing mechanisms don't know any better than to
>> match
>> the first encountered closing brace.  Running from
>> Ant's svn trunk with the 'props' sandbox antlib,
>> however, you can install the nested property
>> expander:
>>
>>   <propertyhelper>
>>     <nested xmlns="antlib:org.apache.ant.props" />
>>   </propertyhelper>
>>
>> This causes the original test to work.  The caveat
>> (beyond the fact that this is only available in an
>> unreleased version of Ant) is that if property 'foo'
>> were defined, ${${foo}} would resolve to the
>> expansion
>> of the expansion of the value of foo.  Actually it
>> should be possible to get around this by using
>> ${$${foo}}, but there seems to be something
>> preventing
>> this.  I'll look into that.
>>     
>
> As an update, there was a bug in the
> NestedPropertyExpander that related to $$ expansion. 
> I have fixed this; however the bad news is that that
> still won't help you because the "thinking the first
> encountered closing brace is the end" problem still
> applies once the internal $$ has been skipped (the
> subsequent { is not recognized as part of a nested
> property so the next } is seen as closing the outer
> property).  It might be possible to introduce some
> other mechanism to recognize delimited strings, but
> I'd have to think more about that.
>
> -Matt
>
>   
>> HTH,
>> Matt
>>
>> --- Stefano Nichele <st...@gmail.com>
>> wrote:
>>
>>     
>>> Hi all,
>>> I have a property with name ${car}. Note that the
>>> name is  not just 
>>> "car"  but ${car}.
>>>
>>> Using echoproperties I see:
>>> [echoproperties] ant.version=Apache Ant version
>>> 1.6.5 compiled on June 2 
>>> 2005
>>> [echoproperties] ${car}=fiat
>>>
>>> How to handle that property ? How to do something
>>> like:
>>>
>>> <echo message="My car: ${car}" />
>>>
>>> since that one doesn't work. Conceptually it
>>>       
>> should
>>     
>>> be <echo message="My 
>>> car: ${${car}}" /> but it doesn't work.
>>>
>>> Thanks a lot
>>> ste
>>>
>>>
>>>       
> ---------------------------------------------------------------------
>   
>>> To unsubscribe, e-mail:
>>> user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail:
>>> user-help@ant.apache.org
>>>
>>>
>>>       
>>
>>       
>>
>>
>>     
> ---------------------------------------------------------------------
>   
>> To unsubscribe, e-mail:
>> user-unsubscribe@ant.apache.org
>> For additional commands, e-mail:
>> user-help@ant.apache.org
>>
>>
>>     
>
>
>
>       
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>   


-- 
Stefano Nichele

Funambol Servers Tech Lead
funambol :: mobile open source :: http://www.funambol.com


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


Re: properties that start with ${..

Posted by Matt Benson <gu...@yahoo.com>.
--- Matt Benson <gu...@yahoo.com> wrote:

> You're in luck.  Maybe.  I tested the following:
> 
>   <property name="$${foo}" value="foo" />
>   <echo>${${foo}}</echo>
> 
> and sure enough, it doesn't work.  This is not so
> much
> because it's no doable as it is because Ant's
> property
> parsing mechanisms don't know any better than to
> match
> the first encountered closing brace.  Running from
> Ant's svn trunk with the 'props' sandbox antlib,
> however, you can install the nested property
> expander:
> 
>   <propertyhelper>
>     <nested xmlns="antlib:org.apache.ant.props" />
>   </propertyhelper>
> 
> This causes the original test to work.  The caveat
> (beyond the fact that this is only available in an
> unreleased version of Ant) is that if property 'foo'
> were defined, ${${foo}} would resolve to the
> expansion
> of the expansion of the value of foo.  Actually it
> should be possible to get around this by using
> ${$${foo}}, but there seems to be something
> preventing
> this.  I'll look into that.

As an update, there was a bug in the
NestedPropertyExpander that related to $$ expansion. 
I have fixed this; however the bad news is that that
still won't help you because the "thinking the first
encountered closing brace is the end" problem still
applies once the internal $$ has been skipped (the
subsequent { is not recognized as part of a nested
property so the next } is seen as closing the outer
property).  It might be possible to introduce some
other mechanism to recognize delimited strings, but
I'd have to think more about that.

-Matt

> 
> HTH,
> Matt
> 
> --- Stefano Nichele <st...@gmail.com>
> wrote:
> 
> > Hi all,
> > I have a property with name ${car}. Note that the
> > name is  not just 
> > "car"  but ${car}.
> > 
> > Using echoproperties I see:
> > [echoproperties] ant.version=Apache Ant version
> > 1.6.5 compiled on June 2 
> > 2005
> > [echoproperties] ${car}=fiat
> > 
> > How to handle that property ? How to do something
> > like:
> > 
> > <echo message="My car: ${car}" />
> > 
> > since that one doesn't work. Conceptually it
> should
> > be <echo message="My 
> > car: ${${car}}" /> but it doesn't work.
> > 
> > Thanks a lot
> > ste
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> > user-help@ant.apache.org
> > 
> > 
> 
> 
> 
>       
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



      

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


Re: properties that start with ${..

Posted by Matt Benson <gu...@yahoo.com>.
You're in luck.  Maybe.  I tested the following:

  <property name="$${foo}" value="foo" />
  <echo>${${foo}}</echo>

and sure enough, it doesn't work.  This is not so much
because it's no doable as it is because Ant's property
parsing mechanisms don't know any better than to match
the first encountered closing brace.  Running from
Ant's svn trunk with the 'props' sandbox antlib,
however, you can install the nested property expander:

  <propertyhelper>
    <nested xmlns="antlib:org.apache.ant.props" />
  </propertyhelper>

This causes the original test to work.  The caveat
(beyond the fact that this is only available in an
unreleased version of Ant) is that if property 'foo'
were defined, ${${foo}} would resolve to the expansion
of the expansion of the value of foo.  Actually it
should be possible to get around this by using
${$${foo}}, but there seems to be something preventing
this.  I'll look into that.

HTH,
Matt

--- Stefano Nichele <st...@gmail.com> wrote:

> Hi all,
> I have a property with name ${car}. Note that the
> name is  not just 
> "car"  but ${car}.
> 
> Using echoproperties I see:
> [echoproperties] ant.version=Apache Ant version
> 1.6.5 compiled on June 2 
> 2005
> [echoproperties] ${car}=fiat
> 
> How to handle that property ? How to do something
> like:
> 
> <echo message="My car: ${car}" />
> 
> since that one doesn't work. Conceptually it should
> be <echo message="My 
> car: ${${car}}" /> but it doesn't work.
> 
> Thanks a lot
> ste
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



      

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