Ant: Copying files

Published: Sunday, 15 August 2004

Using the copy task.

Copying multiple files

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

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

Copying different / modified files

The 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"/>
    </fileset>
</copy>