ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Gentle <j.kenneth.gen...@acm.org>
Subject Re: Expanding properties
Date Fri, 27 Jan 2006 14:18:51 GMT
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