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?
Advertisement
Answer
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).