ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ninju Bohra <ninju_bo...@yahoo.com>
Subject Re: Expanding properties
Date Sat, 28 Jan 2006 02:01:45 GMT
Or you can use the replacefilterfile='file'  attribute on the <replace> task and specify
all the replacements in the 'file'.
 
Later,
 
Ninju
 



----- Original Message ----
From: Ken Gentle <j.kenneth.gentle@acm.org>
To: Ant Users List <user@ant.apache.org>
Sent: Friday, January 27, 2006 8:18:51 AM
Subject: Re: Expanding properties


Untried:

     <!-- defines your properties as tokens -->
     <token file="values.properties"/>
     <!-- Loads the file doing "token" substitution -->
<loadfile srcfile="contents.txt" property="tmp.property">

   <filterchain>

     <replacetokens beginToken="$${" endToken="}" />

   </filterchain>

</loadfile>

HTH...
         Ken

At 06:29 2006-01-27, you wrote:
>Hi
>
>Say I have a file, called contents.txt, which contains the text:
>
>contents.txt:
>The value is ${something}
>
>And I have a property file values.properties which reads
>
>values.propeties:
>something=somevalue
>
>How to I turn contents.txt into
>
>contents.txt:
>The value is somevalue
>
>I can do this with
>
>     <property file="values.properties"/>
>     <replace file="contents.txt">
>       <replacefilter token="${something}" value="${something}"/>
>     </replace>
>
>But this would be painstaking if I had lots of properties to replace - I'd
>have to define each property and then add a <replacefilter> for each one.
>
>I had hoped that this would work:
>
>     <property file="values.properties"/>
>     <loadfile property="temp.property" srcfile="contents.txt"/>
>     <echo message="${temp.property}"/>
>
>But it doesn't - what I'm really after is a way to re-use the in-file
>property expansion performed by <property>. Is there a way to do this?
>
>Tim
>
>Allustra Limited
>85 Gracechurch Street
>London
>EC3V 0AA
>Tel +44 (0)20 7469 8640
>Fax +44 (0)20 7469 8689
>http://www.allustra.com/
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message