如何解决Eclipse插件项目和Tycho之间的JPMS与OSGi Bundle之间的冲突。

huangapple go评论105阅读模式
英文:

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.

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

So the java.xml.* classes are now present twice. 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. 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. removing this creates even more issues
  • The Maven Tycho build seems not to care what I do with the eclipse project module settings.

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.

Does anyone know how to exclude a dependency to a plugin from Eclipse build/Tycho build? Or is there another way to resolve module/OSGi conflicts like this?

英文:

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. 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. 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. removing this creates even more issues
  • The mavan tycho build sees not to care what I do with the eclipse project module settings.

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.

Does anyone know how to exclude a dependency to a plugin from Eclipse build/Tycho build? Or is there another way to resolve module/osgi conflicts like this?

答案1

得分: 4

看起来根本原因org.eclipse.wst.xml.core使用的Xerces版本尚未适用于Java 9或更高版本,并且它重新导出了此依赖项

根据Xerces的发布说明2,至少需要版本2.12.1(目前是最新版本)才能在Java 9或更高版本上运行:

> 在使用Java 9+时,之前的Xerces-J无法从源代码构建。此版本修复了此问题。

Eclipse Orbit(您可以在其中获取已获批准用于商业产品的第三方插件)中,最新版本的Xerces是2.9.0。因此,您需要自己创建一个Xerces 2.12.1插件。如果您能为Eclipse做出这项工作的贡献将会很好(要这样做,请报告给Eclipse WTP Source Editing)。

英文:

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.

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-J was previously not building from sources when Java 9+ was
> used. 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. So you have to create a Xerces 2.12.1 plugin yourself. It would be nice if you could contribute this work to Eclipse (to do so, report it to Eclipse WTP Source Editing).

huangapple
  • 本文由 发表于 2020年7月28日 14:33:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/63128271.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定