使用Ant组合文件集

使用Ant组合文件集,ant,Ant,我在Ant中定义了两个不同的文件集,如下所示: <fileset id="fileset1" dir="${classes.dir}"> </fileset> <zipfileset id="fileset2" src="myArchive.zip" includes="**/*.class"> </zipfileset> 我想创建第三个文件集,它是上述两个文件集的联合体 <fileset id="merged"> </f

我在Ant中定义了两个不同的文件集,如下所示:

<fileset id="fileset1" dir="${classes.dir}">
</fileset>

<zipfileset id="fileset2" src="myArchive.zip" includes="**/*.class">
</zipfileset>

我想创建第三个文件集,它是上述两个文件集的联合体

<fileset id="merged">
</fileset>

有人能告诉我怎么做吗?这样做可能吗?
提前谢谢

试试这个:我认为它应该有效,因为
是一个隐式的


编辑:奇数。也许是这样

<patternset id="merged">
  <patternset refid="fileset1" />
  <patternset refid="fileset2" />
</patternset>

一种方法是使用Ant,特别是一个


然后,您可以在任何可能使用文件集的地方引用“洋葱”,例如

<copy todir="dest">
    <resources refid="onion" />
</copy>


为了获得最大的灵活性,我建议使用通用的
资源
元素而不是文件集。

文件集的问题是,它需要一个目录作为应用模式集的基础。这意味着您必须找到一个由所有文件集共享的公共基本目录

任务可以通过refid获取文件集。您可以放置多个文件集(例如,来自不同的构建目标,以在模块化构建环境的根/主目标中组装复合集):


这可以通过命令行调用,如:

ant-targetA-targetB-targetC根目录

ant-targetA根目录


请注意,root始终是最后一个被调用的目标。

谢谢您的回复。我试过这么做。看起来它需要一个dir属性。Union对我不起作用-在我的例子中,我得到了“xxx不表示文件集”,因为我需要调用的目标需要显式的文件集:
:-\@alexandroid哪个目标需要文件集?也许您可以对其进行修补以接受资源集合!?许多ant任务在版本1.7中针对资源集合进行了重新设计,它是我目前无法直接控制的脚本/包中的目标,不幸的是(我只是称之为)可以工作,但如果您有三个或更多文件集,则会有点麻烦。有没有办法从多个目录获取文件集?可以试试吗?
<fileset id="fileset1" dir="${classes.dir}" />
<zipfileset id="fileset2" src="myArchive.zip" includes="**/*.class" />

<union id="onion">
    <resources refid="fileset1" />
    <resources refid="fileset2" />
</union>
<copy todir="dest">
    <resources refid="onion" />
</copy>