You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Benoît Lubek <be...@pegasis.fr> on 2004/10/27 14:56:43 UTC

Simple manipulation of a property value

Hi,

I have a property :

<property name="version" value="v1.0.2" />

And I'd like to manipulate it a bit, ie, change the "." to "_" (so it 
can be used for a cvs tag). So I'd like to have a property with the 
value "v1_0_2".

Is there a way to do that with the core tasks? I realize it would be 
easy to do it with the <script> task, but I would prefer to avoid the 
need to depend on another jar for our project... Any idea?

Thank you very much for your help.

B.LUBEK

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


Re: Simple manipulation of a property value

Posted by Benoît Lubek <be...@pegasis.fr>.
Thank you all.
I chose Erik's solution, but yours is a good idea too.

Thanks,

-- 
B.LUBEK


Kris Read wrote:
> This is a hack, but: 
> 
> PropertyFile to persist the property to a file. 
> 
> Replace or ReplaceRegExp to alter the value. 
> 
> Then reload from the file. 
> 
> 
> 
> On Wed, 27 Oct 2004 10:04:33 -0400, Erik Hatcher
> <er...@ehatchersolutions.com> wrote:
> 
>>On Oct 27, 2004, at 8:56 AM, Benoît Lubek wrote:
>>
>>>Hi,
>>>
>>>I have a property :
>>>
>>><property name="version" value="v1.0.2" />
>>>
>>>And I'd like to manipulate it a bit, ie, change the "." to "_" (so it
>>>can be used for a cvs tag). So I'd like to have a property with the
>>>value "v1_0_2".
>>>
>>>Is there a way to do that with the core tasks? I realize it would be
>>>easy to do it with the <script> task, but I would prefer to avoid the
>>>need to depend on another jar for our project... Any idea?
>>
>>There is no way to do this without some scripting, that I know of.
>>However, an alternative is to keep the pieces of that property
>>separate:
>>
>>        <property name="part1" value="1"/>
>>        <property name="part2" value="0"/>
>>        <property name="part3" value="2"/>
>>
>>        <property name="version" value="v${part1}.${part2}.${part3}"/>
>>
>>        <property name="version_with_underscores"
>>value="v${part1}_${part2}_${part3}"/>
>>
>>Erik

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


Re: Simple manipulation of a property value

Posted by Kris Read <kr...@gmail.com>.
This is a hack, but: 

PropertyFile to persist the property to a file. 

Replace or ReplaceRegExp to alter the value. 

Then reload from the file. 



On Wed, 27 Oct 2004 10:04:33 -0400, Erik Hatcher
<er...@ehatchersolutions.com> wrote:
> On Oct 27, 2004, at 8:56 AM, Benoît Lubek wrote:
> > Hi,
> >
> > I have a property :
> >
> > <property name="version" value="v1.0.2" />
> >
> > And I'd like to manipulate it a bit, ie, change the "." to "_" (so it
> > can be used for a cvs tag). So I'd like to have a property with the
> > value "v1_0_2".
> >
> > Is there a way to do that with the core tasks? I realize it would be
> > easy to do it with the <script> task, but I would prefer to avoid the
> > need to depend on another jar for our project... Any idea?
> 
> There is no way to do this without some scripting, that I know of.
> However, an alternative is to keep the pieces of that property
> separate:
> 
>         <property name="part1" value="1"/>
>         <property name="part2" value="0"/>
>         <property name="part3" value="2"/>
> 
>         <property name="version" value="v${part1}.${part2}.${part3}"/>
> 
>         <property name="version_with_underscores"
> value="v${part1}_${part2}_${part3}"/>
> 
> Erik
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Simple manipulation of a property value

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Oct 27, 2004, at 8:56 AM, Benoît Lubek wrote:
> Hi,
>
> I have a property :
>
> <property name="version" value="v1.0.2" />
>
> And I'd like to manipulate it a bit, ie, change the "." to "_" (so it 
> can be used for a cvs tag). So I'd like to have a property with the 
> value "v1_0_2".
>
> Is there a way to do that with the core tasks? I realize it would be 
> easy to do it with the <script> task, but I would prefer to avoid the 
> need to depend on another jar for our project... Any idea?

There is no way to do this without some scripting, that I know of.  
However, an alternative is to keep the pieces of that property 
separate:

	<property name="part1" value="1"/>
	<property name="part2" value="0"/>
	<property name="part3" value="2"/>

	<property name="version" value="v${part1}.${part2}.${part3}"/>

	<property name="version_with_underscores" 
value="v${part1}_${part2}_${part3}"/>

Erik


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