I have a desktop JavaFX application using Java 9 modules system, Gradle and IntelliJ. The application builds and runs perfectly with Gradle run task. I am using it without any issue.
Now I am introducing some very simple unit testing with JUnit5, but the test cannot run due to the following module resolution exception
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules xercesImpl and jdk.xml.dom export package org.w3c.dom.html to module commons.logging
My build.gradle looks like:
plugins {
id 'java'
id 'org.javamodularity.moduleplugin' version '1.8.12'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
repositories {
mavenCentral()
}
dependencies {
implementation project(':api')
implementation 'org.xerial:sqlite-jdbc:3.41.2.2'
implementation 'org.odftoolkit:odfdom-java:0.12.0'
implementation 'com.hummeling:if97:2.0.0'
testImplementation(platform('org.junit:junit-bom:5.10.1'))
testImplementation 'org.junit.jupiter:junit-jupiter'
}
tasks.named('test', Test) {
useJUnitPlatform()
}
Why is this conflict happening only in the testing run? How am I supposed to resolve this type of issue? Many thanks!
Recalling and older post related to Odfdom problems, I found that it was sufficient to exclude
xercesImplmodule for the test run. With the following dependencies configuration the unit test now works: