I am getting the following error when trying to run a Spring Boot test with coverage in Intellij.
Caused by: java.lang.LinkageError: loader 'bootstrap' attempted duplicate class definition for java.lang.$JaCoCo. (java.lang.$JaCoCo is in module java.base of loader 'bootstrap')
I am using Java 17 Temurin
with Gradle 7.6
and I’ve switched the coverage runner to be Jacoco as shown in the screenshot below.
I am also using Jacoco 0.8.8
, but I’m not explicitly stating the version from Gradle. I am instead, using the plugin as is as a part of the test stage.
apply plugin: 'jacoco'
...
test {
jacoco {
excludes = [
'org/hibernate/**/*__$*$__*'
]
}
environment "SPRING_PROFILES_ACTIVE", "test"
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
}
If I remove the jacoco plugin from gradle, then it works because there isn’t a duplicate JVM entry for jacoco (from Intellij and Gradle).
Is there a way for gradle to use jacoco from Intellij, or vice-versa? I want to be able to configure jacoco from gradle, but still view the coverage in the coverage window in intellij.