ant-user mailing list archives

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

src/HTML-XForm/lib
src/ResPath/lib
src/XML-MSXML6/lib

You get the idea, it is:

src/*/lib

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.*"/>
      </fileset>
      <!-- portability: path separator logic redoubled in regexp -->
      <mapper type="regexp" from="^[-_a-zA-Z0-9]*[\\/]lib(.*)" to="\1"/>
    </copy>
  </target>
</project>

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 
Mime
View raw message