ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Alberto Fernandez" <j_a_fernan...@yahoo.com>
Subject RE: Replace task - getting *tokens* from a properties file?
Date Wed, 13 Jun 2001 15:37:37 GMT
> From: Jon Skeet [mailto:jon.skeet@peramon.com]
> 
> I'm trying to convert our company's build procedure to Ant. I'm doing
> pretty well (with the addition of a couple of tasks - 
> CopyProperty which
> sets the value of one specified property to the value of another; I
> think it's the only way of doing effectively ${${embedded}.property},
> and works well enough for now, and FailUnless which simply 
> fails unless
> a given property is set - I need this because "if" doesn't resolve
> property values (ie doing if="${project}" doesn't resolve project and
> then test whether or not that name has is set), but I've run 
> up against
> something slightly trickier.
> 

Is this due to the fact that ${project}'s value containg the name of the
property you need to check? some srt of templating?

> 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.
> 

Why? The whole point of ANT is to be expandable. 

I would suggest writing a small task which just extends <replace>. And it
just calls createReplacefilter() with values from the property file, before
calling super.execute(). 

You can always contribute it, if not to CORE, to the list of tasks available
from 3rd parties. 

Jose Alberto

> Jon
> 

Mime
View raw message