ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Cryder" <christi...@enhydra.org>
Subject Submission: CopyAndReplace
Date Mon, 10 Sep 2001 18:13:01 GMT
Hi folks,

I'm not sure how to go about the submission process here, so I'll just send
this to the list and let you review...

I've created a CopyAndReplace taskdef that extends the basic Copy
functionality to perform a text Replace on all the files that get copied. I
tried to use the filter approach, but the text I needed to replace was not
in @ signs (or any particular tag identifier). I also tried doing it
manually in two separate steps: copy, then replace (both on the same
fileset). The problem there was that the replace ended up affecting other
files that were in the target directory, rather than just those which got
copied.

So finally I ended up creating a custom taskdef to do what I needed in one
fell swoop.

You invoke the taskdef like this:

  <copy_and_replace
      todir="${target.dir}"
	mappings="${mappings.file}" >
      <fileset ... />
  </copy_and_replace>

As you can see, everything is identical to the <copy> taskdef, except that
you include an additional reference to a mappings file. I've attached a
sample along with the actual CopyAndReplace taskdef to illustrate
everything. All in all, its pretty straightforward and seems to work quite
well. Please feel free to use it or discard it as you see fit. You may make
any modifications necessary.

Hope others will find it helpful...
Christian
------------------------------------------------
Christian Cryder [christianc@enhydra.org]
Barracuda - MVC Component Framework for Webapps
http://barracuda.enhydra.org
------------------------------------------------
        "What a great time to be a Geek"

Mime
View raw message