ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ludwig, Michael" <>
Subject simplify copy with regexpmapper (mapper/regexp)
Date Thu, 16 Sep 2010 14:02:31 GMT
Consider this filtered view of my directory tree:


You get the idea, it is:


Now I want to copy the files below src/*/lib, or most of them.
And I want to strip the leading two directories. I came up with
the following solution, but it is clumsy and I think there is
a better way that I'm missing.

<project default="copy">
  <property name="source.dir" location="src"/>
  <property name="target.dir" location="lib"/>

  <target name="copy">
    <copy todir="${target.dir}">
      <fileset dir="${source.dir}">
        <include name="*/lib/**/*.*"/>
        <exclude name="**/urmel.*"/>
      <!-- portability: path separator logic redoubled in regexp -->
      <mapper type="regexp" from="^[-_a-zA-Z0-9]*[\\/]lib(.*)" to="\1"/>

What I'm wondering is if there isn't some option like in tools such
as wget (--cut-dirs to shorten the path) or cpio or tar, which in
Ant's case would probably translate to a mapper, like cut-dirs-mapper.

Michael Ludwig 
View raw message