I have a gradle build that uses javafx, log4j from maven and jOpenDocument-1.5 from a jar in a local flatDir (folder). When I build under JDK19 I get the following errors
error: the unnamed module reads package org.w3c.dom from both jOpenDocument and java.xml
error: module javafx.graphicsEmpty reads package org.w3c.dom from both jOpenDocument and java.xml
error: module javafx.baseEmpty reads package org.w3c.dom from both jOpenDocument and java.xml
error: module org.apache.logging.log4j.core reads package org.w3c.dom from both jOpenDocument and java.xml
error: module javafx.controlsEmpty reads package org.w3c.dom from both jOpenDocument and java.xml
error: module jOpenDocument reads package org.w3c.dom from both java.xml and jOpenDocument
Gradle provides a collection of mechanisms that should allow me to exclude the org.w3c.com package from the build. Gradle wants me to specify a "group" and/or a "module", but the error messages specify a "java package" but not the group and module names.
I would like the build to use the org.w3c.dom package from java.xml and exclude the org.w3c.dom package from jOpenDocument. I chose the java.xml variant of the package because the jOpenDocument variant has just org.w3c.dom.UserDataHandler.class so removing it should make it less likely to have side-effects in other dependencies.
The Gradle build scans did not go down to a package level analysis. It doesn't really tell me anything I can act on. That may be more my ignorance.
The following snippet from my build.gradle file is what I have now. It doesn't work probably because org.w3c.dom is a package and not a gradle/maven module.
dependencies {
testImplementation 'org.testng:testng:7.4.0'
implementation 'org.apache.logging.log4j:log4j-api:2.14.1'
implementation 'org.apache.logging.log4j:log4j-core:2.14.1'
implementation ('libs:jOpenDocument-1.5') {
exclude module: 'org.w3c.dom'
}
}
I removed the /org/w3c/dom/UserDataHandler.class file and its parent folder at org/w3c/dom from the JAR file (JAR files being ZIP files) manually. (Thank you @Slaw)
... job done. Note that I have yet to test whether there are any functional side-effects.
The latest version (jOpenDocument-1.5.jar) is not on Maven. So, I could edit the JAR manually in my local flat directory repository. I used ark to do the deleting. That may change - I see a request has been made. I would prefer to use officially published versions from Maven because they more maintainable over the long term. So, towards the end of development, I will have a go at enhancing my build.gradle file to perform this edit programmatically, most likely using jar commands, as suggested by @jewelsea,
Two closing thoughts if I may.