可以使Maven构建包含来自依赖项的.class文件 [英] Possible to make maven build include .class files from dependencies

查看:98
本文介绍了可以使Maven构建包含来自依赖项的.class文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

手动将我的API依赖的每个.jar的内容拖到我的已编译.jar中,已经相当麻烦了,我想知道maven是否有任何功能可以自动提取.class文件.依赖项并将它们添加到它编译的.jar文件中,这将使工作变得非常简单,尤其是在进行大量构建以进行测试时.当我必须以.zip格式打开.jar并试图修复错误时每分钟将源代码放入5-10次时,它会变得非常烦人,而且很快.

It's become quite a drag to manually drag the contents of each .jar my API depends on into my compiled .jar so it will work properly, and I was wondering if there was any functionality for maven to automatically extract the .class files of the dependencies and add them to the .jar file it compiles, this would make life so much simpler, especially when doing numerous builds for testing. When I have to open my .jar as a .zip, and drop in the sources 5-10 times a minute when trying to fix a bug, it gets really annoying, really quickly.

我已经对此进行了大量的搜索,但是我什么也没发现,只有一堆链接说明了如何向Maven添加依赖项,但是没有向Maven构建中添加依赖项的内容. /p>

I've done quite a bit of googling on this, but I've found nothing, just a bunch of links explaining how to add dependencies to maven, but nothing on adding the contents of a dependency to a maven build.

推荐答案

使用maven shade插件创建一个"Uber" Jar,其中包含JAR中pom中定义的依赖项.

Use the maven shade plugin to create an "Uber" Jar that contains the dependencies defined in the pom within your JAR

http://maven.apache.org/plugins/maven- shade-plugin/index.html

这篇关于可以使Maven构建包含来自依赖项的.class文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆