How to copy a directory using Ant

Sunil Kumar Sahoo picture Sunil Kumar Sahoo · Nov 6, 2009 · Viewed 88.3k times · Source

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?

Answer

ery picture ery · Dec 14, 2011

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