mauromol · GitHub

I'm trying to upgrade my project which uses HtmlUnit from Java 8 to Java 11.

I have the following classpath problem. HtmlUnit indirectly depends on xml-apis and this may make the Java 11 compiler complain:

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

This happens even if I'm not using the module path, but the classpath.

I see that HtmlUnit 2.56 has the following dependency:

        <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
            <version>2.7.2</version>
            <exclusions>
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

which is fine, because it excludes xml-apis. However, it also depends on neko-htmlunit, which in turn has the following dependency:

        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.12.1</version>
        </dependency>

with no exclusion for xml-apis, which is transitively required by xercelImpl, so xml-apis:xml-apis:1.4.01 falls transitively into the classpath, requiring consumer applications to exclude it explicitly on their own.

Could this be fine-tuned?

Read the original on github.com ↗