Yes, you can use the regexp mapper:
<copy todir="${dest}">
<fileset dir="${source}" includes="**/ant.jar"/>
<mapper type="regexp" from=".*ant.jar" to="internal/ant.jar"/>
</copy>
The doc for the glob filemapper is correct, 0 or 1 stars are allowed, both
for the to and from attributes.
The doc does not say what zero stars means.
For the to field, it means an implicit * at the end of the attribute.
Peter
Phil Weighill-Smith wrote:
(Sorry if this message is HTML: having to use Outlook Web Access and don't know
how to control the mail format!)
Thanks for the info. Note that the documentation for the file mappers states that "to" and "from"
can "contain at most one '*'", which implies to me that they can legitimately have zero stars. In this
particular case the fileset defined selects just one file, ant.jar, which is what I want to copy to a different
directory. The problem is that I don't know (in the Ant script) the exact path to the ant.jar so I'm using
"**/ant.jar":
<copy todir="${dest}">
<fileset dir="${source}" includes="**/ant.jar"/>
<mapper type="glob" from="*/ant.jar" to="internal/ant.jar"/>
</copy>
What I want to do is copy the one and only "${source}/.../ant.jar" to "${dest}/internal/ant.jar". Because the
Ant script is itself generated (generically) such that the copy "todir" attribute is fixed as "${dest}" I
can't simply set that to "${dest}/internal" and use a flatten mapper which is what I'd otherwise do.
If you can think of a way of doing this processing with just changing the body
content of the copy element and not the copy element itself I'd love to know
the solution! Perhaps the regexp mapper would do this?
Phil :n(
-----Original Message-----
From: Dominique Devienne [mailto:[EMAIL PROTECTED]
Sent: Fri 13/08/2004 19:07
To: Ant Developers List
Cc:
Subject: RE: Bug in the "glob" file mapper?
> From: Phil Weighill-Smith [mailto:[EMAIL PROTECTED]
> The "glob" file mapper is exhibiting a behaviour I didn't expect:
>
> <copy ...
> <fileset ...
> <mapper type="glob" from="*/ant.jar" to="internal/ant.jar"/>
> </copy>
>
> Assuming that "*" matches "env/apache-ant-1.6.2/lib" I expected this
to
> copy the ant.jar to a destination of copy's todir + /internal/ant.jar.
> What it actually does is copy it to copy's todir +
> /internal/ant.jarenv/apache-ant-1.6.2/lib.
>
> I.e. if you don't use a "*" in the to attribute of the mapper, the "*"
> match is suffixed onto the "to". This seems wrong to me. Is this a
bug?
It's wrong in the sense that the glob mapper should most likely throw an
error when the "*" is missing in the 'to' attribute.
You can't use the glob mapper to concatenate files like this, and even
if it worked, plain concatenation wouldn't work with .jar files.
Use <concat> for plain concatenation.
Use <jar> or <zip> with <zipfileset> for concatenation of JAR/ZIP files.
--DD
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]