Ant: Copying files

Using the <copy> task.

Copying multiple files

    <copy todir="target/xml/dir">
      <fileset dir="src/xml">
        <include name="**/*.xml"/>

Copies all xml files found in src/xml to target/xml/dir

Copying different / modified files

different is handy when you want to copy only files that have had their content modified, and ignore the timestamp. For example:

  <copy todir="${dist.dir}">
    <fileset dir="${build.dir}" includes="**/*.*">
      <different targetdir="${dist.dir}" ignoreFileTimes="true"/>

Published: Sunday, 15 August 2004