给定一个源文件目录,如下所示:
tester$ ls -l src
-rw-r--r-- 1 tester staff 0 24 Feb 11:28 File 1.txt
-rw-r--r-- 1 tester staff 0 24 Feb 11:28 File 2.txt
-rw-r--r-- 1 tester staff 0 24 Feb 11:28 File 3.txt
-rw-r--r-- 1 tester staff 0 24 Feb 11:30 FileFalse 1.txt
-rw-r--r-- 1 tester staff 0 24 Feb 11:30 FileFalse 2.txt
-rw-r--r-- 1 tester staff 0 24 Feb 11:30 FileFalse 3.txt
我可能会尝试使用以下命令将它们全部复制到另一个位置fileset
:
<project name="test" default="copy">
<target name="copy">
<mkdir dir="build"/>
<copy todir="build">
<fileset dir="src" includes="File *.txt"/>
</copy>
</target>
</project>
但是include=
将空格(和逗号)视为分隔符,因此这被视为包括“文件”和“* .txt” - 因此它实际上复制了每个文件。文档没有提到如果您想在模式中使用文字字符,您将如何转义该字符,并且阅读源代码,似乎他们根本没有放入任何转义机制。
我们在构建中遇到了一个真正的问题,但我们只匹配一个文件,所以作为一种解决方法,我只使用了<fileset file="..."/>
.
但是,一般来说,文件的数量可能很大,或者您可能不想在每次文件更改时更新构建,那么正确的方法是什么?