简体   繁体   English

Java 9模块和uber-jar

[英]Java 9 modules and uber-jar

When developing Java libraries we're currently using the Apache Maven Shade Plugin to hide internal dependencies on other libraries (jars) by renaming their package names. 在开发Java库时,我们目前正在使用Apache Maven Shade Plugin通过重命名其包名来隐藏其他库(jar)的内部依赖性。

Is it possible to hide these internal library-dependencies by using the Java 9 module system and not exporting the name of the internally used libraries? 是否可以通过使用Java 9模块系统隐藏这些内部库依赖项,而不是导出内部使用的库的名称? Ie: 即:

  1. Both module A and B include, but does not export, class org.codehaus.jackson.map.ObjectMapper (included using eg Maven Shade plugin) with different versions for the class 模块A和B都包含但不导出类org.codehaus.jackson.map.ObjectMapper(包含使用例如Maven Shade插件),具有不同版本的类
  2. Module A uses module B 模块A使用模块B.

Will each module still use its implementation org.codehaus.jackson.map.ObjectMapper? 每个模块是否仍然使用它的实现org.codehaus.jackson.map.ObjectMapper?

I believe it should by so, but I have found no documentation explicitely confirming this, nor any texts / examples recommending this approach for this quite usual versioning issue. 我相信它应该这样,但我发现没有明确证实这一点的文档,也没有任何文本/示例为这个相当常见的版本问题推荐这种方法。

This issue is described as http://openjdk.java.net/projects/jigsaw/spec/issues/#MultiModuleExecutableJARs and there's no support for it yet. 这个问题被描述为http://openjdk.java.net/projects/jigsaw/spec/issues/#MultiModuleExecutableJARs ,但它还没有支持。 In case all dependencies are modules, it would make sense to use jlink to solve this. 如果所有依赖项都是模块,那么使用jlink来解决这个问题是有意义的。 But as long as there is at least one non-module, there's no solution available yet. 但只要至少有一个非模块,就没有可用的解决方案。 This is something that needs to be solved within the JDK/JRE. 这是需要在JDK / JRE中解决的问题。 It is still a valid case, so I would suggest to ask this question the at jigsaw-dev mailinglist and refer to #MultiModuleExecutableJARs 它仍然是一个有效的案例,所以我建议在jigsaw-dev邮件列表中提出这个问题,并参考#MultiModuleExecutableJARs

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

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