gradlex-org / extra-java-module-info

A Gradle 6.8+ plugin to use legacy Java libraries as Java Modules in a modular Java project
Apache License 2.0
104 stars 6 forks source link

[Maybe] Add removePackage feature to deal with split-packages in JDK Modules (for example xerces:xercesImpl) #140

Open wardeneta opened 2 months ago

wardeneta commented 2 months ago

Hello, I tried your plugin and there was a problem with this library

implementation 'xerces:xercesImpl:2.12.2'

which contains the package org.w3c.dom, which is part of jdk.xml.dom. how to solve it in this case? Thanks

jjohannes commented 1 month ago

Hi, I am afraid this can't be solved with the plugin right now.

As you have a conflict with a Module in the JDK itself – jdk.xml.dom – you can't use the mergeJar functionality, as you cannot modify a Module of the JDK itself.

I think this should really be solved in xerces. It is this issue: https://issues.apache.org/jira/browse/XERCESJ-1689

Looks like it was fixed months ago, but never released. 😞


We could think about adding a new functionality to this plugin that allows you to completely remove a package from a Jar. As we already do filtering of Jar entries and allow to ignore service providers:

extraJavaModuleInfo {               
    module("groovy-all-2.4.15.jar", "groovy.all", "2.4.15") {
       ignoreServiceProvider("org.codehaus.groovy.source.Extensions")
    }
}

We could add something similar to remove a package:

extraJavaModuleInfo {               
    module("xerces:xercesImpl", "xerces.impl)") {
       removePackage("org.w3c.dom.html") // THIS IS A MOCKUP, we do not have this yet
    }
}

I am would be open for contributions.