如果我有这样的文件集:
<fileset dir=".">
<exclude name="classes/*"/>
<include name="**/zar.class"/>
</fileset>
排除优先于include,我不会以任何类结束。 [因为对于这个假设的例子,zar.class在类dir中]我想包含zar文件,即使它在类dir中。
我对这个问题猛烈抨击了一段时间,阅读有关选择器,模式集,文件集,尝试合并文件集等等但无法使其正常工作。
任何人都知道怎么做?
答案 0 :(得分:4)
为什么需要exclude元素?
<fileset dir=".">
<include name="**/zar.class"/>
</fileset>
应该为您提供完整的文件集:zar.class,以及类/中没有其他.class
个文件。
只需将其置于社区维基模式,因为我不确定,在第二个想法,它实际上是你所追求的:
你可能想要所有,包括类/.../ zar.class,除了类/....
我的解决方案只会给你zar.class。
请发表评论:如果这不是一个好的解决方案,我会将其删除。
答案 1 :(得分:2)
我不确定你想要什么,但我认为你在正确的轨道上看着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>
答案 2 :(得分:1)
在原始问题中使用了哪个版本的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,它就在它旁边。