简体   繁体   English

Maven:包含带有与其他依赖项冲突的捆绑库的第3方jar

[英]Maven: Include 3rd party jar with bundled libraries that conflict with other dependencies

I've been looking for the answer to this for a few days and have turned up empty. 我一直在寻找答案的几天,结果却空无一人。

I'm devving a Confluence plugin that integrates with a 3rd party app. 我正在设计一个Confluence插件,该插件可与第三方应用程序集成。 This 3rd party app has a nice REST API and they even provide a Java SDK (yay!). 这个第三方应用程序具有不错的REST API,甚至还提供了Java SDK(是!)。 Except.....the Java SDK has bundled a version of Jersey (1.18) that conflicts with Confluence's forked version of Jersey (1.8-atlassian_15). 除了……Java SDK捆绑了一个版本的Jersey(1.18),该版本与Confluence的分叉版本的Jersey(1.8-atlassian_15)相冲突。 The SDK was not released as a Maven jar (or at least there's no pom.xml included). 该SDK并未作为Maven jar发布(或者至少不包含pom.xml)。 There ARE other pom.xml in the jar's META-INF for the dependencies it uses, but the SDK itself is just released as a jar download by the vendor. jar的META-INF中还有其他pom.xml用于其使用的依赖项,但供应商只是将SDK本身作为jar下载发布。

So as I've done in the past, I mvn install:install-file the sucker with my own groupId and artifactId, thinking it'd be fine. 因此,就像我过去所做的那样,我用自己的groupId和artifactId来mvn install:install-file吸盘,以为会没事的。 Intellij recognized the library, everything compiled nicely, and then I tried my test call to the REST API. Intellij识别了该库,所有内容都进行了很好的编译,然后我尝试对REST API进行测试调用。 This is when it threw an error that made it evident that there's a conflict between the versions. 这是当它抛出一个错误,表明版本之间存在冲突时。

SOOOO. 太好了 Is there anyway to get around this? 反正有解决这个问题的方法吗? Can I "sandbox" the SDK jar in a way the executes code in its own deal without being exposed to the nasties of Confluence's builtin version of libraries the SDK uses? 我是否可以以一种可以自行执行代码的方式来“沙盒化” SDK jar,而不会暴露于SDK使用的Confluence内置库版本的麻烦? I have a feeling that even after the Jersey dependency is resolved (if that's even possible) there will be other issues....The SDK also bundles the specific version of Jackson, Swagger, etc. with it. 我有一种感觉,即使解决了Jersey依赖关系(即使有可能),也会有其他问题。...SDK还将捆绑特定版本的Jackson,Swagger等。

I attempted to decompile the jar and include the decompiled code in my project, but that just had all of issues I'd rather not deal with ever again. 我试图反编译jar并将反编译后的代码包含在我的项目中,但这只是我不想再处理的所有问题。

I have reached out the SDK devs to see if they could release a more maven-friendly release, but I'm not hopeful this will be done at all, and even it is, their release cycle is much different than my own requirements (read: I need a solution now). 我已经联系了SDK开发人员,看他们是否可以发布更适合Maven的版本,但是我完全不希望这样做,即使如此,他们的发布周期也与我自己的要求有很大不同(阅读:我现在需要一个解决方案)。 This is my last-ditch effort before rewriting the REST client from scratch. 这是我从头开始重写REST客户端之前的最后努力。

Can I "sandbox" the SDK jar in a way the executes code in its own deal without being exposed to the nasties of Confluence's builtin version of libraries the SDK uses? 我是否可以以一种可以自行执行代码的方式来“沙盒化” SDK jar,而不会暴露于SDK使用的Confluence内置库版本的麻烦?

Sure you can. 你当然可以。 Often-used way to do this is to use Maven shade plugin that transforms an existing jar to a shaded jar , using another package hierarchy and getting rid of the package naming conflict. 经常使用的方法是使用Maven阴影插件 ,该插件将现有的jar转换为带阴影的jar ,使用另一个包层次结构并摆脱包命名冲突。 See also the documentation about relocating packages . 另请参阅有关重新定位软件包的文档。 I suggest you use that - that's what I've done in cases like this (though I haven't done confluence plugin development, but it should be the same thing as with other platforms). 我建议您使用-这是我在类似情况下所做的(尽管我尚未完成融合插件的开发,但应该与其他平台一样)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM