I have used copydir
to copy a directory tree but it is deprecated. My directory contains some sub-directories, and some of those contain files and others contai
I'm adding a more generic pattern to copy all subfolders.
<copy todir="${dest.dir}" >
<fileset dir="${src.dir}" includes="**/*"/>
</copy>
See Patterns for details.
A fine point: ant will only copy the sub-directories if the source files are newer than the destination files. [1] In my case, the sub-dirs were not being copied (I am using verbose="true"), since there were no changes and they were already in the destination. You can use "overwrite" to force it, or touch some of the files in your source sub-dirs.
Copy contents including the directory itself.
<copy todir="${dest.dir}" >
<fileset dir="${src.dir.parent}">
<include name="${src.dir}/**"/>
</fileset>
</copy>
Note: ${src.dir} is relative to ${src.dir.parent}, and not a full path
You should only have to specify the directory (sans the includes property):
<copy todir="../new/dir">
<fileset dir="src_dir"/>
</copy>
See the manual for more details and examples.
From the example here, you can write a simple Ant file using copy task.
<project name="MyProject" default="copy" basedir=".">
<target name="copy">
<copy todir="./new/dir">
<fileset dir="src_dir"/>
</copy>
</target>
</project>
This should copy everything inside src_dir
(excluding it) to new/dir
.