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:同时使用include和exclude_Ant_Include_Fileset - Fatal编程技术网

Ant:同时使用include和exclude

Ant:同时使用include和exclude,ant,include,fileset,Ant,Include,Fileset,好的,这看起来应该很简单。我使用的是Apache Ant 1.8,我有一个目标: <delete file="output/program.tar.bz2"/> <tar basedir="input" destfile="output/program.tar.bz2" compression="bzip2"> <tarfileset dir="input"> <include name="goodfolder1/**"/> &

好的,这看起来应该很简单。我使用的是Apache Ant 1.8,我有一个目标:

<delete file="output/program.tar.bz2"/>
<tar basedir="input" destfile="output/program.tar.bz2" compression="bzip2">
  <tarfileset dir="input">
    <include name="goodfolder1/**"/>
    <include name="goodfolder2/**"/>
    <exclude name="**/badfile"/>
    <exclude name="**/*.badext"/>
  </tarfileset>
</tar>

我想让它为input/goodfolder1和input/goodfolder2生成一个.tar.bz2,不包括名为“badfile”的文件,也不包括扩展名为“.badext”的文件。它给了我一个.tar.bz2,但它包括了badfile和*.badext——排除项似乎被忽略了

包含/排除的顺序似乎没有什么区别。我试着将includes/excludes包装在一个文件中(文档说它是隐式的?),但没有任何区别

我确信我遗漏了一些简单的东西,因为,尽管在不同的背景下


编辑:看起来它可能与
dir=“input”
属性有关:它在“input”中添加所有内容,然后在tarfileset中添加所有内容。我想要的文件在program.tar.bz2中出现两次,但被排除的文件只出现一次。但是
dir
是强制性的,我看不出这与手册中的示例有什么不同。

我认为您需要使用两个
元素。
元素仅用于文件。不适用于目录。例如:


啊,
本身就是造成我问题的原因


如果我删除它,并将include/excludes直接放在
中,它就可以正常工作。

include
exclude
模式可以用于文件或文件夹。您可能会想到
includefile
excludesfile