本文介绍了组合多个罐子的干净方法?最好使用 Ant的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对一些外部 jar 有运行时依赖,我想将它们rejar"到单个 jar 中.这些外部依赖项存储在 external_jars 目录中,我希望不必将它们全部列出(即,如果我的依赖项发生变化,则不需要更改我的构建脚本).有什么想法吗?

I have runtime dependencies on some external jars that I would like to "rejar" into a single jar. These external dependencies are stored in an external_jars directory, and I'd like to be able to not have to list them all (i.e., not to need to change my build scripts if my dependencies change). Any thoughts?

Google 就如何执行此操作给了我一个很好的答案 - 如果您不介意将每个 jar 列为依赖项:

Google gave me a good answer on how to do this - if you don't mind listing out each jar as a dependency:

http://markmail.org/message/zijbwm46maxzzoo5

粗略地说,我想要一些类似于以下内容的东西,它将 lib 目录中的所有 jar 组合到 out.jar(具有一些合理的覆盖规则).

Roughly, I want something along the lines of the following, which would combine all jars in the lib directory into out.jar (with some sane overwrite rules).

jar -combine -out out.jar -in lib/*.jar

推荐答案

只需将 zipgroupfileset 与 Ant 压缩任务

Just use zipgroupfileset with the Ant Zip task

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

这将扁平化所有包含的 jar 库的内容.

This will flatten all included jar libraries' content.

这篇关于组合多个罐子的干净方法?最好使用 Ant的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 16:49