3

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?

greg-449
  • 109,219
  • 232
  • 102
  • 145
Dieter
  • 120
  • 7
  • 1
    If I understand it correctly, you face this issue because `org.eclipse.wst.xml.core` uses Xerces in a version that is not yet ready for Java 9 or higher, and unfortunately also [reexports this dependency](https://git.eclipse.org/c/sourceediting/webtools.sourceediting.git/tree/xml/bundles/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF#n313). Then the right thing would be in `org.eclipse.wst.xml.core` to update Xerces to [2.12.1](http://xerces.apache.org/xerces2-j/releases.html), right? I guess Eclipse WTP would welcome such a contribution. – howlger Aug 03 '20 at 09:57
  • 1
    Thank you for your answer @howlger . With your information, i was able to implement a quick fix by building xerces 2.12 as a plug-in and using it in the build. of course, fixing the issue in `org.eclipse.wst.xml.core` would be better for everyone. I will see what i can do regarding this. – Dieter Aug 03 '20 at 12:33

1 Answers1

4

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).

howlger
  • 31,050
  • 11
  • 59
  • 99