-----Original Message-----
From: bmilbr...@outstart.com [mailto:bmilbr...@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)
[...]
*/
sorry, forget my first post, to get the original package structure
in stagedir it has to be =
<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>
[echo] Patchdir = C:\patches\patch01
[copy] Copying 2 files to C:\stagedir
[copy] Copying C:\patches\patch01\com\foo\classes\good\Good.class to
C:\stagedir\com\foo\classes\good\Good.class
[copy] Copying C:\patches\patch01\com\foo\classes\bad\Bad.class to
C:\stagedir\com\foo\classes\bad\Bad.class
[echo] Patchdir = C:\patches\patch02
[copy] Copying 2 files to C:\stagedir
[copy] Copying C:\patches\patch02\com\foo\classes\bad\Bad.class to
C:\stagedir\com\foo\classes\bad\Bad.class
[copy] Copying C:\patches\patch02\com\foo\classes\ugly\Ugly.class to
C:\stagedir\com\foo\classes\ugly\Ugly.class
Regards, Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org