How do I use Ant to copy a folder?

ant, copy

Solution

First of all, those are the examples from Ant documentation:

Copy a directory to another directory

<copy todir="../new/dir">
  <fileset dir="src_dir"/>   
</copy>

Copy a set of files to a directory

<copy todir="../dest/dir">
  <fileset dir="src_dir">
    <exclude name="**/*.java"/>
  </fileset>
</copy>

<copy todir="../dest/dir">
  <fileset dir="src_dir" excludes="**/*.java"/>   
</copy>

Copy a set of files to a directory, appending .bak to the file name on the fly

<copy todir="../backup/dir">
  <fileset dir="src_dir"/>
  <globmapper from="*" to="*.bak"/>   
</copy>

Secondly, here is the whole documentation about copy task.

Problem

I'm trying to copy a directory using the Ant `copy` task. I am a newbie at Ant; my current solution is: ``` <copy todir="${release_dir}/lib"> <fileset dir="${libpath}" /> </copy> ``` I'm wondering if there is a better and shorter way to accomplish the same thing?

Original source

Related problems