Bug 32379 - Enhance token definition for replacefilterfile in replace task
Summary: Enhance token definition for replacefilterfile in replace task
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.6.2
Hardware: PC Windows XP
: P2 enhancement with 3 votes (vote)
Target Milestone: ---
Assignee: Ant Notifications List
Depends on:
Reported: 2004-11-24 13:51 UTC by Chris Lewold
Modified: 2008-11-24 03:58 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lewold 2004-11-24 13:51:42 UTC
My property file(s) has properties like env.dir.base etc. 
I have various config files which are "master" files, and used to create the 
final config file (based on the contents of the property files). 

In the master file however I don't want to write 
<config basedir="env.dir.base">

Instead I want to be able to make it clearly visible by enclosing the strings 
to be replaced into delimiters. E.g. 
<config basedir="%env.dir.base%">

I could achieve this by writing the property files like: 
%env.dir.base% = /dir/val/used 

.... but .... this is ugly. I don't want property names to contain the 
delimiter characters (%). 

Provide an optional argument "delimiterstring" to be used with 
replacefilterfile. E.g. 

<replace file="e:\\test.txt" 

And now don't treat each property as token, but instead use %property% as 
Comment 1 Steve Loughran 2004-11-24 14:39:46 UTC
I believe that you can do this by using a <filterset> in the <copy> task.
Comment 2 Chris Lewold 2004-11-25 10:48:06 UTC
That's a good tip, which basically works. 
We have just one problem: We use "nested tokens". E.g. 
%cost.%delivery.system%% --> %cost.cd%   (in first replace iteration) 
%cost.cd% --> 100 (in second replace iteration) 

We could solve this by copying the file to a temp file first, and then to the 
final file. But somehow I don't like that - I would prefer to replace contents 
in one file. 

I think exactly those begin/endtoken from filterset would fit perfectly into 
the Replace task. 

Additionally there is one problem with filterset. ${} Variables don't get 
replaced. The same problem happens with the replace task also, but only when 
using replacefilterfile. 
I think this is already reported with defect 8972 however. If you know a 
workaround there it would rock.