Wednesday, May 9, 2012

How to copy the directory using Ant


I have used copydir to copy the directory. Actually my directory contains some sub-directories, and some of those contain files and others contain sub-directories. How do I copy everything?



Source: Tips4all

4 comments:

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


    believe that will do what you want...

    ReplyDelete
  2. 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.

    ReplyDelete
  3. 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.

    ReplyDelete
  4. Copy contents including the directory itself.

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

    ReplyDelete