如何使用 ant 任务递归复制文件和目录

How to do recursive copy of files and directories using ant task

Ant 内置复制任务来复制多个文件。 我试图在 build.xml 文件

中定义以下目标
 <target name="copyFile">
        <copy todir="../CHECK">
            <fileset dir=".">
                <patternset id="AllFiles">
                    <include name="*"/>
                </patternset>
        </fileset>
        </copy>
   </target>

正在复制文件和目录。但是目录中的内容不会被复制,而是将目录作为空目录复制到目标“../CHECK”。 Ant 复制任务是否提供递归复制文件和目录的能力

我找到了答案 include 中的名称模式应该是“**”而不是“*”。它对所有内容进行递归复制

  <target name="copyFile">
            <copy todir="../CHECK">
                <fileset dir=".">
                    <patternset id="AllFiles">
                        <include name="**"/>
                    </patternset>
            </fileset>
            </copy>
       </target>