ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: problem: how to copy multiple directories in ant
Date Tue, 20 Jan 2009 08:06:46 GMT


-----Original Message-----
From: bmilbratz@outstart.com [mailto:bmilbratz@outstart.com]
Sent: Monday, January 19, 2009 6:55 PM
To: user@ant.apache.org
Subject: problem: how to copy multiple directories in ant

/*
Hi,

I have a well-defined problem I can easily solve via a shell script, but
want to know the ant-equivalent. This issue has come up on the ant user
mailing list before, but no answer surfaced. I've tried using various
combinations of fileset and dirset, but without success. Can someone
offer some insights?

The problem:
================
I have a directory structure like this:

  |-patches
  |---patch01
  |-----com
  |-------foo
  |---------classes
  |-----------bad
  |--------------Bad.class
  |-----------good
  |--------------Good.class
  |-----------ugly
  |---patch02
  |-----com
  |-------foo
  |---------classes
  |-----------bad
  |--------------Bad.class
  |-----------good
  |-----------ugly
  |--------------Ugly.class


I want to copy all the '.class' files in the ' patches/*/com'
directories to an output directory "staging_classes", i.e. so I end up
with the directory structure:
  |-staging_classes
  |-----com
  |-------foo
  |---------classes
  |-----------bad
  |--------------Bad.class (from patch02)
  |-----------good
  |--------------Good.class (from patch01)
  |-----------ugly
  |--------------Ugly.class (from patch02)

[...]

*/

<project name="bla" default="main" basedir=".">

<!-- // Taskdefs -->
<!-- Import AntContrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<!-- Taskdefs // -->

<!-- // Properties -->
<property name="patchroot" value="C:/patches"/>
<property name="stagedir" value="C:/stagedir"/>
<!-- Properties // -->

<target name="main">
  <for param="patchdir">
    <dirset dir="${patchroot}" includes="**/patch*/**" />
    <sequential>
      <echo>Patchdir = @{patchdir}</echo>
      <copy todir="${stagedir}" overwrite="true" verbose="true">
        <fileset dir="@{patchdir}" includes="*/*.class" />
      </copy>
    </sequential>
  </for>
</target>

</project>


Regards, Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message