How to copy a directory from one place to another using Ant?

I want to copy a directory from one place to another. However, after looking at "copy" and "copyDir" (which is deprecated), it seems that by default Ant only copies the contents of one place to another, and not the actual directory (and everything in it).

So, as an example, I have the following:

./Foo/test.txt

And I applied the following Ant snippet:

 <copy todir="./build">
    <fileset dir="./Foo"/>
 </copy>

The result is as follows:

./build/test.txt

While I would like to:

./build/Foo/test.txt

Hope this makes sense. How can i do this?

+5
source share
2 answers

, . copy flatten, false. , .

:

a <fileset> ,      todir . ,      <fileset>          ,      <fileset> , true.

, Foo, , Foo, , ~/Foo/ file.txt .

+3

:

<copy todir="./build">
  <fileset dir=".">
    <include name="Foo/**"/> 
  </fileset>
</copy>
+3

All Articles