Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

Re: Filter on copy with directory contents

David Weintraub

2008-02-21

Replies: Find Java Web Hosting

Author LoginPost Reply
Well, the @REPLACE@(protected).
The tricky part is finding the value for ${replacing}.

You might be able to do something with the AntContrib <PropertyRegex>
task. This can take a property and munge it.

Let's say you do something like this:

<path id="replaceme">
  <fileset dir="${replace.dir}">
    <include name="*.jar"/>
  </fileset>
</path>

<property name="replace.string" refid="replaceme"/>

This will give you ${replace.string} = "foo.jar:bar.jar:fobar.jar"

Not what you want, but then you can use <propertyregex>

<propertyregex
  property="munge.replace"
  input="${replace.string}"
  regexp="[;:]"
  replace="</string>"<string>"
  global="true"/>

That will give you ${munge.replace} =
"foo.jar</string><string>bar.jar</string><string>foobar.jar"

Then, we need to add a prefix and suffix:

<property name="munge.replace2"
  value="<string>${munge.replace}</string>"/>

It's all on a single line and not separate lines, but XML doesn't care.

<copy toDir="${dest.dir}">
<fileset dir="${src.dir}">
  <include name="*.jar">
</fileset>
<filterset
  token="REPLACEME"
  value="${munge.replace2"/>
</copy>

Haven't tested it, but something like that should work.

On Wed, Feb 20, 2008 at 4:20 PM, Paul J. Lucas <pauljlucas@(protected):
> Given a file that contains:
>
>      @REPLACEME@
>
> I want to use <copy> to copy the file and replace @REPLACEME@(protected)
> contents like:
>
>      <string>foo.jar</string>
>      <string>bar.jar</string>
>      ...
>
> where "foo" and "bar" are the names of the file(s) in a particular
> directory that match a certain pattern (in this case *.jar).
>
> Is there a way to do that? I've read the docs but the answer isn't
> all that obvious. Thanks.
>
> - Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>



--
--
David Weintraub
qazwart@(protected)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.