ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kai Bartels <k...@picturesafe.de>
Subject Re: Replace task - getting *tokens* from a properties file?
Date Wed, 13 Jun 2001 15:38:03 GMT
On Wed, Jun 13, 2001 at 03:36:36PM +0100, Jon Skeet wrote:
> In my old build procedure I had a few steps which take a normal file
> (.java or whatever) and a properties file. The properties file had, for
> instance:
> 
> Version=foo
> Name=bar
> 
> I have a little Java program which looks through the properties file,
> finds all the properties within it, then does a replace on all the
> "normal" files using these properties wrapped in <%...%>. In this case,
> it would be the equivalent of:
> 
> <replace {insert src files here}>
>   <replacefilter token="<%Version%>" value="foo"/>
>   <replacefilter token="<%Name%>" value="bar"/>
> </replace>
> 
> However, I'd like the property files to determine the tokens, as my
> previous build did.
> 
> I can probably hack something up in Replace, something like:
> 
> <multiplereplacefilter file="xxx.properties" prefix="<%" postfix="%>" />
> 
> but I'm not sure that such a patch would get accepted. (Speaking of
> which, has anyone glanced at my Zip and VSS patches yet?)
> 
> It feels slightly silly to create a whole new task for something so
> similar to Replace.
> Ideas welcome.
> 
> Jon

Hi Jon.

As fas as I understand your problem description, the filtering mechanism of the
copy task should help you. Just define tokens to be filtered like this:
<filter token="Version" value="${build.vers}"/>
...
and copy your source template file into your source tree before compiling with:
<copy tofile="mysrc.java" filtering="on" file="mysrc.java.templ"/>

Have you been looking for this?

Kai
-- 
"Day, n. A period of twenty-four hours, mostly misspent. This period is
 divided into two parts, the day proper and the night, or day improper --
 the former devoted to the sins of business, the latter consecrated to the
 other sort. These two kinds of social activity overlap."    <Ambrose Bierce>
KBartels@picturesafe.de                  +                 www.picturesafe.de
picturesafe GmbH, Lueerstr. 3, D-30175 Hannover          fon:+49 511 85620 56
++ PGP Key fingerprint =  D2 B9 58 DC 36 52 DB 6C  18 CC 43 9F 68 E0 21 97 ++

Mime
View raw message