在使用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脚本时,看到以下输出:
all:
[delete] Deleting directory /home/grodriguez/workspace/_test/anttest/dst
[mkdir] Created dir: /home/grodriguez/workspace/_test/anttest/dst
[copy] Copying 1 file to /home/grodriguez/workspace/_test/anttest/dst
[copy] Copied 4 empty directories to 1 empty directory under /home/grodriguez/workspace/_test/anttest/dst
问题:为什么蚂蚁报告正在复制“ 4个空目录”?那不应该是1个空目录(com / foo / bar)吗?
答案 0 :(得分:1)
创建目录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
时,它(显然)是空的,因此被计为4,即使在复制完成时它不是空的。