ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <>
Subject Re: Newbie ant question
Date Thu, 20 Mar 2003 15:16:58 GMT
Included is a simple stringreplace... (it only takes one param)
(Cut and paste police may cringe at the code....)
<copy file="dm-example.xml" tofile="dm-example.xml.cdata">
       <filterreader classname="my.custom.ant.StringReplace"
           <param name="&amp;" value="&amp;amp;"/>
       <filterreader classname="my.custom.ant.StringReplace"
           <param name="&lt;" value="&amp;lt;"/>

one may also use <if/> from ant-contrib.
    <copy file="dm-example.xml" tofile="dm-example.xml.cdata" 
    <replace file="dm-example.xml.cdata" token="&amp;" value="&amp;amp;"/>
    <replace file="dm-example.xml.cdata" token="&lt;" value="&amp;lt;"/>

included On Thursday 20 March 2003 14:02, Stefan Bodewig wrote:
> On Thu, 20 Mar 2003, Norman Walsh <> wrote:
> > Yes, I understand that, I'm just wondering if there's some simpler
> > ant idiom for expressing the conditionality of a target.
> In general tasks are supposed to do the dependency checking.  <copy>
> does so and it works for it.  <replace> will not touch your file if
> there was nothing to replace - unfortunately there will always be
> something to replace in your case.
> The "simpler idiom" in this case probably would be a filterreader that
> performed the replacements you need while copying the files.  This
> would give you several benefits as you'd get the dependency tracking
> working and the files wouldn't have to be openend, read, written and
> closed three times.
> Unfortunately there isn't such a replace-filter built-in into Ant
> (yet), but several people have asked for it, both a simple and a
> regular expression version.
> Stefan
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message