Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant 其中";“空目录”;你是被蚂蚁复制的吗?_Ant - Fatal编程技术网

Ant 其中";“空目录”;你是被蚂蚁复制的吗?

Ant 其中";“空目录”;你是被蚂蚁复制的吗?,ant,Ant,在使用ant作为构建工具的项目中,我有以下简化的目录结构: src/ com/ foo/ bar/ (some files) bar2/ (some other files) 以及以下简化的ant脚本: <project default="all"> <target name="all"> <delete dir="dst"/>

在使用
ant
作为构建工具的项目中,我有以下简化的目录结构:

src/
   com/
      foo/
         bar/
            (some files)
         bar2/
            (some other files)
以及以下简化的ant脚本:

<project default="all">
    <target name="all">
        <delete dir="dst"/>
        <mkdir dir="dst"/>
        <copy todir="dst">
            <fileset dir="src" excludes="com/foo/bar/*"/>
        </copy>
    </target>
</project>

问:为什么ant报告正在复制“4个空目录”?那不应该是一个空目录(com/foo/bar)吗?

创建目录
com/foo/bar
意味着首先创建
com
,然后创建
com/foo
——即三个目录

我的Ant版本稍微详细一些,显示了每个创建操作:

$ ant -v
Apache Ant(TM) version 1.10.2 compiled on February 3 2018
... deleted for brevity ....
    [mkdir] Created dir: /stack/ant/dst
     [copy] com/foo/bar2/x.txt added as com/foo/bar2/x.txt doesn't exist.
     [copy]  omitted as /stack/ant/dst is up to date.
1    [copy] com added as com doesn't exist.
2    [copy] com/foo added as com/foo doesn't exist.
3    [copy] com/foo/bar added as com/foo/bar doesn't exist.
4    [copy] com/foo/bar2 added as com/foo/bar2 doesn't exist.
     [copy] Copying 1 file to /stack/ant/dst
     [copy] Copying /stack/ant/src/com/foo/bar2/x.txt to /stack/ant/dst/com/foo/bar2/x.txt
     [copy] Copied 4 empty directories to 1 empty directory under /stack/ant/dst

当创建
bar2
时,它(显然)是空的,因此被包括在四个计数中,即使在复制完成时它不是空的。

/bar/
下有dir吗?没有,只有文件。有趣的是,如果我在构建脚本中用
替换
,未报告“空目录”的复制。。。
$ ant -v
Apache Ant(TM) version 1.10.2 compiled on February 3 2018
... deleted for brevity ....
    [mkdir] Created dir: /stack/ant/dst
     [copy] com/foo/bar2/x.txt added as com/foo/bar2/x.txt doesn't exist.
     [copy]  omitted as /stack/ant/dst is up to date.
1    [copy] com added as com doesn't exist.
2    [copy] com/foo added as com/foo doesn't exist.
3    [copy] com/foo/bar added as com/foo/bar doesn't exist.
4    [copy] com/foo/bar2 added as com/foo/bar2 doesn't exist.
     [copy] Copying 1 file to /stack/ant/dst
     [copy] Copying /stack/ant/src/com/foo/bar2/x.txt to /stack/ant/dst/com/foo/bar2/x.txt
     [copy] Copied 4 empty directories to 1 empty directory under /stack/ant/dst