Unable to generate Jacoco report using gradle task

20 views
Skip to first unread message

Ruby Verma

unread,
May 17, 2024, 2:45:42 AMMay 17
to JaCoCo and EclEmma Users
Hi All,

I want to generate jacoco html report from an existing coverage.ec file for an Android application. I have generated this coverage file from the Instrumentation automation run.


Whenever I'm running the Gradle task for report generation, I get the following error:

Task :app:jacocoTestReport FAILED

My grade task is as follows:
tasks.register('jacocoTestReport', JacocoReport) {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.required = true
html.required = true
}

def fileFilter = ['**/R*.class',
'**/*$InjectAdapter.class',
'**/*$ModuleAdapter.class',
'**/*$ViewInjector*.class']

def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"

sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([debugTree]))

//My coverage file path
executionData.setFrom(files("${project.projectDir}/src/coverage.ec"))

doFirst {
new File("$buildDir/intermediates/classes/").eachFileRecurse { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
}

I have the following jacoco version: 
classpath "org.jacoco:org.jacoco.core:0.8.8"

Has anyone come across the same problem? Any input will be highly appreciated!!

Thanks
Reply all
Reply to author
Forward
0 new messages