It's not that hard ...
<copy todir="${copy.dir}"> <fileset dir="temp"> <include name="**/dir3/**"/> </fileset> </copy>
When you use the include directive, it will only contain files that match the template that you give it. In this case, I copy only those files that have /dir3/ located somewhere along their full path. This includes subdirectories under dir3 and all files under dir3 .
You can use the exclude directive to override include directives:
<copy todir="${copy.dir}"> <fileset dir="temp"> <include name="**/dir3/**"/> <exclude name="**/dir3/*"/> </fileset> </copy>
This will copy all the subdirectories and files in these subdirectories, but not the files under dir3 . * matches all files in a directory, and ** matches all files of the entire directory tree.
Note that this will create the temp/dir2/dir3 . If I want temp/dir3 , I have to install my set of files in the parent directory dir3 :
<copy todir="${copy.dir}"> <fileset dir="temp/dir2"> <include name="dir3/**"/> </fileset> </copy>
Performing this action:
<copy todir="${copy.dir}"> <fileset dir="temp/dir2/dir3"/> </copy>
Creates a temp directory with all files directly under dir3 directly under temp . There will also be a temp/dir4 and temp/dir5 containing all the files (and directory trees) in these directories.
source share