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_Include_Fileset - Fatal编程技术网

如何让Ant包含文件集优先于排除文件集

如何让Ant包含文件集优先于排除文件集,ant,include,fileset,Ant,Include,Fileset,如果我有这样一个文件集: <fileset dir="."> <exclude name="classes/*"/> <include name="**/zar.class"/> </fileset> exclude优先于include,我不会得到任何类。[因为对于这个假设的例子,zar.class在classes dir中]我想包括zar文件,即使它在classes dir中 有一段时间,我在阅读选择器、模式集、文件集、试图组

如果我有这样一个文件集:

<fileset dir=".">
  <exclude name="classes/*"/>
  <include name="**/zar.class"/>   
</fileset>

exclude优先于include,我不会得到任何类。[因为对于这个假设的例子,zar.class在classes dir中]我想包括zar文件,即使它在classes dir中

有一段时间,我在阅读选择器、模式集、文件集、试图组合文件集等方面的内容时,脑袋撞了一下这个,但没能让它工作


有人知道怎么做吗?

我不确定你到底想要什么,但我认为你在研究pattersets时走对了方向:怎么样:

<patternset id="a">
  <exclude name="classes/*"/>
</patternset>

<patternset id="b">
  <include name="**/zar.class"/>  
</patternset>

<fileset dir=".">
  <patternset refid="a" />
  <patternset refid="b" />
</fileset>

为什么需要exclude元素

<fileset dir=".">
  <include name="**/zar.class"/>   
</fileset>

应该给你一组你想要的文件:zar.class,而不是class/中的其他
.class
文件


把它放在社区维基模式下,因为我不确定,经过再三考虑,它是否真的是你想要的:
您可能需要所有内容,包括class/../zar.class,除了class/

我的解决方案只会给你一个等级


请留下评论:如果这不是一个好的解决方案,我将删除它。

原始问题中使用了哪个版本的Ant

在Ant 1.8.2中,节确实会产生所需的结果

<fileset dir="." id="some.fileset">
    <exclude name="build/classes/*" />
    <include name="**/A.class" />
</fileset>

<target name="test">
    <pathconvert pathsep="${line.separator}" property="listed.fileset" refid="some.fileset"/>
    <echo message="${listed.fileset}" />
</target>

路径和名称略有不同,但此确实显示了A.class,而不显示它旁边的B.class