在Maven和Java 9中将第三方工件与拆分包一起使用 [英] Use third party artifacts with split packages in Maven and Java 9

查看:118
本文介绍了在Maven和Java 9中将第三方工件与拆分包一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使我的项目适合Java 9,并且遇到拆分包(共享同一包的工件)问题.

I am trying to make my project ready for Java 9 and I am running into problems with split packages (artifacts sharing the same package).

我的应用程序至少依赖于两个第三方遗留工件(它们是使用Java< 9构建的).当我使用Java 9运行Maven时,我得到:

My application depends on at least two third-party legacy artifacts (that are built with Java <9). When I run Maven with Java 9, I get:

[ERROR] module myapp reads package P from both A and B

这是正确的,因为包P存在于A.jar和B.jar中,但没有重叠的类.我了解这是Java 9的问题,我在--patch-module <package>=<path-to-jar>). 在此处还有另一种想法,

Which is correct, since the package P exists in A.jar and B.jar, but without overlapping classes. I understand that this is a problem for Java 9 and I studied suggested solutions in https://blog.codefx.org/java/java-9-migration-guide/#fixes-2 . To summarize it is either "Fix your code" (not possible, since third-party JAR) or "Run with command line options" (Where the most interesting may be --patch-module <package>=<path-to-jar>). There was another idea here, which said

将第3方模块之一(或两者)包装在一个简单的模块中,该模块仅执行显式导出模块实际需要的程序包,什么都不做.

wrap one of the 3rd party modules (or both) in a simple module, which does nothing but explicitly exports only the package(s) that are actually needed by your module.

但是我如何在Maven(3.5.0)中实现此目标,目前我只拥有一个<dependency>和maven-compiler-plugin:3.7.0-我不想静态地重新打包第三方JAR?

But how can I achieve this in Maven (3.5.0), where all I currently have is a <dependency> and the maven-compiler-plugin:3.7.0 - and I don't want to statically repackage third party JARs?

欢迎提供任何示例提示或提示.

Any hint or pointer to an example would be welcome.

推荐答案

请检查 http://mail-archives.apache.org/mod_mbox/felix-users/200709.mbox/%3CF034315F398DE24C9A76FB51DAFAB709FC9638@nets13ga.ww300.siemens.net%3E

示例为我工作:

<Export-Package>
  org.hibernate.*;version=${pkgVersion};-split-package:=merge-last                       

</Export-Package>

相同的答案在: 为什么要获得此拆分包"?警告?

这篇关于在Maven和Java 9中将第三方工件与拆分包一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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