How to copy a directory using Ant

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 contain more sub-directories.

How can I copy the entire tree?


Solution 1:

<copy todir="${dest.dir}" >  
    <fileset dir="${src.dir}" includes="**"/>  
</copy> 

believe that will do what you want... (Recursive copy done)

Solution 2:

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