tags:

views:

545

answers:

1
+3  A: 

See the replace task:

<replace 
   dir="mydir" 
   includes="foo, bar, baz">
   <replacefilter token="OLD" value="NEW" />
</replace>

or the replaceregexp task:

<replaceregexp
    file="${src}/build.properties"
    match="OldProperty=(.*)"
    replace="NewProperty=\1"
    byline="true"/>
Kevin
Thanks, but it turns out that my question is incomplete. I "simplified" my production code too much when I wrote this question. I neglected to specify the need for regular expression filtering, which replace does not appear to support (please correct me if I'm wrong!). You've given a great answer for the case without the need for regular expresssions.
Greg Mattes
In that case, see the optional replaceregexp task: http://ant.apache.org/manual/OptionalTasks/replaceregexp.html
Kevin
The optional tasks! Genius! I've probably looked through the Ant optional tasks twice in my life. Totally forgot they were there. Thanks! Please add a new answer using the replaceregexp task, or edit this answer and I'll accept it. Here, I'll make it easy for you (notice the flags="g" to catch all occurrences):<replaceregexp match="OLD([0-9])" replace="NEW\1" flags="g"> <fileset dir="mydir"/></replaceregexp>
Greg Mattes