ant 迭代文件

发布于 2024-07-15 02:00:14 字数 336 浏览 5 评论 0原文

我想迭代 jar 列表(未定义的数量)并将它们全部添加到 jar 文件中。 要添加它们,我计划使用这样的东西:

<jar id="files" jarfile="all.jar">
   <zipfileset src="first.jar" includes="**/*.java **/*.class"/>
   <zipfileset src="second.jar" includes="**/*.java **/*.class"/>
</jar>

但是如何迭代它们? 我没有 ant-contrib

谢谢!

I want to iterate over a list of jars (undefined number) and add them all to the jar file.
To add them I plan to use something like this:

<jar id="files" jarfile="all.jar">
   <zipfileset src="first.jar" includes="**/*.java **/*.class"/>
   <zipfileset src="second.jar" includes="**/*.java **/*.class"/>
</jar>

but how do I iterate over them? I don't have ant-contrib

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坦然微笑 2024-07-22 02:00:15

只需将 zipgroupfileset 与 Ant Zip 任务 结合使用

<zip destfile="out.jar">
    <zipgroupfileset dir="lib" includes="*.jar"/>
</zip>

即可将展平所有包含的 jar 库的内容。

Just use zipgroupfileset with the Ant Zip task

<zip destfile="out.jar">
    <zipgroupfileset dir="lib" includes="*.jar"/>
</zip>

This will flatten all included jar libraries' content.

墨落画卷 2024-07-22 02:00:15

如果您无权访问 ant-contrib < code>对于任务,您最终可能必须定义您的自定义任务用于执行您需要的操作...

如果您有 ant1.6 及更高版本,您还可以尝试subant (请参阅 适用于大型项目的新 Ant 1.6 功能):

如果您使用 genericantfile 属性,它的工作方式类似于 在同一位置调用目标包含任务的构建文件。
不同, 采用目录列表或目录集,并为设置项目基目录的每个目录调用一次目标。

如果您想在任意数量的目录中执行完全相同的操作,这非常有用。

If you do not have access to ant-contrib For task, you may end up to have to define your custom Task for doing what you need...

If you have ant1.6 and above, you can also try subant (see New Ant 1.6 Features for Big Projects):

If you use <subant>'s genericantfile attribute it kind of works like <antcall> invoking a target in the same build file that contains the task.
Unlike <antcall>, <subant> takes a list or set of directories and will invoke the target once for each directory setting the project's base directory.

This is useful if you want to perform the exact same operation in an arbitrary number of directories.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文