If I have a fileset like this:
如果我有这样的文件集:
<fileset dir=".">
<exclude name="classes/*"/>
<include name="**/zar.class"/>
</fileset>
The exclude takes precedence over the include and I don't end up with any classes. [since for this hypothetical example, zar.class is in the classes dir] I would like to include the zar file, even though it is in the classes dir.
排除优先于include,我不会以任何类结束。 [因为对于这个假设的例子,zar.class在类dir中]我想包含zar文件,即使它在类dir中。
I banged my head against this one for a while, reading about selectors, patternsets, filesets, trying to combine filesets, etc. but could not get it working.
我对这个问题猛烈抨击了一段时间,阅读有关选择器,模式集,文件集,尝试组合文件集等但无法使其正常工作。
Anyone know how to do this?
有人知道怎么做吗?
3 个解决方案
#1
Why do you need the exclude element ?
为什么需要exclude元素?
<fileset dir=".">
<include name="**/zar.class"/>
</fileset>
should give you the exact set of files you are after: zar.class, and none of the other .class
files in classes/.
应该为您提供以下文件的确切集合:zar.class,以及类/中的其他.class文件。
Just put this in community wiki mode, because I am not sure, on second thought, that it is actually what you are after:
you may want everything, including classes/.../zar.class, except classes/....
只是把它放在社区维基模式中,因为我不确定,在第二个想法,它实际上是你所追求的:你可能想要一切,包括类/.../ zar.class,除了类/ ....
My solution would only give you zar.class.
我的解决方案只会给你zar.class。
Please leave a comment: if this is not a good solution, I will remove it.
请留言:如果这不是一个好的解决方案,我会将其删除。
#2
I'm not sure exactly what you want but I think you were on the right track looking at pattersets: How about:
我不确定你想要什么,但我认为你在正确的轨道上看着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>
#3
Which version of Ant was used in the original question?
在原始问题中使用了哪个版本的Ant?
With Ant 1.8.2, the stanza does produce the desired result!?
使用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>
Path and name slightly different, but this does show A.class, and does not show B.class, which is right next to it.
路径和名称略有不同,但这确实显示了A.class,并且没有显示B.class,它就在它旁边。
#1
Why do you need the exclude element ?
为什么需要exclude元素?
<fileset dir=".">
<include name="**/zar.class"/>
</fileset>
should give you the exact set of files you are after: zar.class, and none of the other .class
files in classes/.
应该为您提供以下文件的确切集合:zar.class,以及类/中的其他.class文件。
Just put this in community wiki mode, because I am not sure, on second thought, that it is actually what you are after:
you may want everything, including classes/.../zar.class, except classes/....
只是把它放在社区维基模式中,因为我不确定,在第二个想法,它实际上是你所追求的:你可能想要一切,包括类/.../ zar.class,除了类/ ....
My solution would only give you zar.class.
我的解决方案只会给你zar.class。
Please leave a comment: if this is not a good solution, I will remove it.
请留言:如果这不是一个好的解决方案,我会将其删除。
#2
I'm not sure exactly what you want but I think you were on the right track looking at pattersets: How about:
我不确定你想要什么,但我认为你在正确的轨道上看着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>
#3
Which version of Ant was used in the original question?
在原始问题中使用了哪个版本的Ant?
With Ant 1.8.2, the stanza does produce the desired result!?
使用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>
Path and name slightly different, but this does show A.class, and does not show B.class, which is right next to it.
路径和名称略有不同,但这确实显示了A.class,并且没有显示B.class,它就在它旁边。