简体   繁体   English

如何解决 JPMS 和 OSGi Bundle 之间的冲突,用于 Eclipse 插件项目和 Tycho

[英]How to resolve conflict between JPMS and OSGi Bundle for Eclipse plugin project an Tycho

I am working on an Eclipse based project that recently switched from Java 1.8 to Java 11. Due to that we have now a conflict between classes from the JRE and classes that are introduced from Eclipse plugin dependencies. I am working on an Eclipse based project that recently switched from Java 1.8 to Java 11. Due to that we have now a conflict between classes from the JRE and classes that are introduced from Eclipse plugin dependencies.

The package javax.xml.parsers is accessible from more than one module: <unnamed>, java.xml

So the java.xml.* classes are now present twice.所以 java.xml.* 类现在出现了两次。 once from the module java.xml and once due to a dependency from our plugin to org.eclipse.wst.xml.core once from the module java.xml and once due to a dependency from our plugin to org.eclipse.wst.xml.core

org.eclipse.wst.xml.core -> org.apache.xerces -> javax.xml

What I would like to do is exclude the module java.xml or the bundle javax.xml from being included in the build.我想做的是将模块 java.xml 或包 javax.xml 排除在构建中。 I found this post with an explanation on how to exclude the module but for multiple reasons I can't do it like this:我发现这篇文章解释了如何排除模块,但由于多种原因我不能这样做:

  • many other modules depend on java.xml.许多其他模块依赖于 java.xml。 removing this creates even more issues删除它会产生更多问题
  • The mavan tycho build sees not to care what I do with the eclipse project module settings. mavan tycho build 并不关心我如何处理 eclipse 项目模块设置。

At this point I think the best solution is to exclude javax.xml from being included in the build but I was unable to find a way how to do this inside eclipse and for the tycho build.在这一点上,我认为最好的解决方案是将 javax.xml 从构建中排除,但我无法找到如何在 eclipse 和 tycho 构建中执行此操作的方法。

Does anyone know how to exclude a dependency to a plugin from Eclipse build/Tycho build?有谁知道如何从 Eclipse build/Tycho build 中排除对插件的依赖? Or is there another way to resolve module/osgi conflicts like this?或者还有其他方法可以解决这样的模块/osgi 冲突吗?

It looks like the root cause is that org.eclipse.wst.xml.core uses Xerces in a version that is not yet ready for Java 9 or higher and that it reexports this dependency .看起来根本原因org.eclipse.wst.xml.core在尚未准备好 ZD52387880E1EA22817A72D375921389 或更高版本的版本中使用 Xerces

According to the release notes of Xerces at least version 2.12.1 (which is currently the latest version) is required for Java 9 or higher:根据Xerces的发行说明, Java 9 或更高版本至少需要版本2.12.1 (目前是最新版本):

Xerces-J was previously not building from sources when Java 9+ was used.当使用 Java 9+ 时,Xerces-J 以前不是从源构建的。 This release fixes this.此版本修复了此问题。

In Eclipse Orbit (where you can get third-party plugins that are approved to be used also in commercial products) is the latest version of Xerces 2.9.0.Eclipse Orbit (您可以获得被批准用于商业产品的第三方插件)中是 Xerces 2.9.0 的最新版本。 So you have to create a Xerces 2.12.1 plugin yourself.所以你必须自己创建一个 Xerces 2.12.1 插件 It would be nice if you could contribute this work to Eclipse (to do so, report it to Eclipse WTP Source Editing ).如果您能将这项工作贡献给 Eclipse,那就太好了(为此, 请将其报告给 Eclipse WTP Source Editing )。

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

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