Unable to generate Jacoco report with JDK17

75 views
Skip to first unread message

Thomas Keller

unread,
Jan 29, 2024, 8:26:55 AMJan 29
to JaCoCo and EclEmma Users
Hi all!

I'm using Jacoco 0.8.11 and I'm in the process of migrating my JDK11 project to JDK17. 

Unfortunately, the coverage report no longer lists any visited classes as covered and the command line tells me

[ant:jacocoReport] Classes in bundle 'app' do not match with execution data. For report generation the same class files must be used as at runtime.

[ant:jacocoReport] Execution data for class my/company/package/DeliveryPreferenceMapper does not match.

[ant:jacocoReport] Execution data for class my/company/package/TransportListMapper does not match.

[ant:jacocoReport] Execution data for class my/company/package/AddressConsigneeMapper does not match.

I'm clueless here, because _everything_ is properly configured for JDK 17:

 

------------------------------------------------------------

Gradle 8.5

------------------------------------------------------------

Build time:   2023-11-29 14:08:57 UTC

Revision:     28aca86a7180baa17117e0e5ba01d8ea9feca598

Kotlin:       1.9.20

Groovy:       3.0.17

Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023

JVM:          17.0.9 (Eclipse Adoptium 17.0.9+9)

OS:           Mac OS X 14.1.1 aarch64


Then, on project level (it's an Android project)

def javaVersion = JavaVersion.VERSION_17
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}

and finally, the output of `javap -v path/to/DeliveryPreferenceMapper.class` tells me

...

public interface path.to.DeliveryPreferenceMapper

  minor version: 0

  major version: 61

I.e. JDK17.

This is my JacocoReport task configuration:

tasks.register("create${variantName.capitalize()}Coverage", JacocoReport) {
dependsOn(tasks.named("compile${variantName.capitalize()}JavaWithJavac"))
group = "Reporting"
description = "Generate Jacoco coverage reports on the ${variantName.capitalize()} build."

def fileFilter = [ /* snip */ ]

def javaTree = fileTree(layout.buildDirectory.dir("intermediates/javac/$variantName/classes")) {
exclude(fileFilter)
}
def kotlinTree = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/$variantName")) {
exclude(fileFilter)
}
additionalClassDirs.from = files(javaTree, kotlinTree)
executionData.from = files(layout.buildDirectory.file("outputs/unit_test_code_coverage/${taskFolder}/${testTaskName}.exec"))
def coverageSourceDirs = ["src/main/java",
"src/$variantName/java",
"src/$productFlavorName/java",
"src/$buildTypeName/java"]

sourceDirectories.setFrom(files(coverageSourceDirs))
additionalSourceDirs.setFrom(files(coverageSourceDirs))

reports {
csv.required = false
xml.required = true
xml.outputLocation = layout.buildDirectory.file('test-results/coverage/coverage.xml')
html.required = true
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}

Any idea what I might doing wrong?

Thanks!

Thomas Keller

unread,
Jan 29, 2024, 10:03:14 AMJan 29
to JaCoCo and EclEmma Users
Ok, nevermind, I switched to kotlinx-kover and dropped all of my hand-rolled code. There I don't see any issues. Sorry for the noise.
Reply all
Reply to author
Forward
0 new messages