buildr:将依赖项打包到单个 jar 中
我有一个使用 buildr 构建的 java 项目,并且具有一些外部依赖项:
repositories.remote << "http://www.ibiblio.org/maven2"
repositories.remote << "http://packages.example/"
define "myproject" do
compile.options.target = '1.5'
project.version = "1.0.0"
compile.with 'dependency:dependency-xy:jar:1.2.3'
compile.with 'dependency2:dependency2:jar:4.5.6'
package(:jar)
end
我希望它构建一个包含所有这些依赖项的单个独立 jar 文件。
我怎么做?
(有一个合乎逻辑的后续问题: 我怎样才能删除所有包含的依赖项中未使用的代码,仅打包我实际使用的类?)
I have a java project that is built with buildr and that has some external dependencies:
repositories.remote << "http://www.ibiblio.org/maven2"
repositories.remote << "http://packages.example/"
define "myproject" do
compile.options.target = '1.5'
project.version = "1.0.0"
compile.with 'dependency:dependency-xy:jar:1.2.3'
compile.with 'dependency2:dependency2:jar:4.5.6'
package(:jar)
end
I want this to build a single standalone jar file that includes all these dependencies.
How do I do that?
(there's a logical followup question: How can I strip all the unused code from the included dependencies and only package the classes I actually use?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这就是我现在正在做的事情。 这使用 autojar 仅提取必要的依赖项:
以及稍后:
(警告:我对构建器知之甚少,这可能是完全错误的方法。不过,它对我有用)
This is what I'm doing right now. This uses autojar to pull only the necessary dependencies:
and later:
(caveat: I know little about buildr, this could be totally the wrong approach. It works for me, though)
我也在学习 Buildr,目前我正在以这种方式将 Scala 运行时与我的应用程序打包:
不知道这是否不如 autojar(欢迎评论),但似乎可以使用一个简单的示例。 需要 4.5 分钟才能打包 scala-library.jar 认为的内容。
I'm also learning Buildr and currently I'm packing Scala runtime with my application this way:
No idea if this is inferior to autojar (comments are welcome), but seems to work with a simple example. Takes 4.5 minutes to package that scala-library.jar thought.
我将使用 Cascading 作为示例:
I'm going to use Cascading for my example:
以下是我如何使用 Buildr 创建 Uberjar,对 Jar 中放入的内容以及如何创建 Manifest 进行自定义:
还有一个版本 通过连接所有spring.schemas来支持Spring
Here is how I create an Uberjar with Buildr, this customization of what is put into the Jar and how the Manifest is created:
There is also a version that supports Spring, by concatenating all the spring.schemas