I have been looking for a solution for days for merging multiple Jacoco
reports for a multi-module Android project in order to send them off to Sonarcloud
at once. I have already checked tons of Stackoverflow posts and other things such as blogs, Github repositories, Gradle forum, etc but unfortunately none of solutions works for me.
I would really appreciate if anybody here shares a sample project or code piece with me.
Gradle version: 7.0.2
Kotlin version: 1.5.21
JDK: 11
Below code piece also doesn't work for me
/**
* Root task that generates an aggregated Jacoco test coverage report for all sub-projects
*/
task jacocoFullReport(type: JacocoReport, group: 'Coverage reports') {
group = 'Reporting'
description = 'Generates an aggregate report from all subprojects'
tasks.withType(Test) {
ignoreFailures true
}
def projects = subprojects
//noinspection GrUnresolvedAccess
dependsOn(projects.jacocoReport)
final source = files(projects.jacocoReport.sourceDirectories)
additionalSourceDirs.setFrom source
sourceDirectories.setFrom source
classDirectories.setFrom files(projects.jacocoReport.classDirectories)
executionData.setFrom files(projects.jacocoReport.executionData)
reports {
html {
enabled true
destination file('build/reports/jacoco/html')
}
csv {
enabled true
destination file('build/reports/jacoco/jacocoFullReport.csv')
}
}
doFirst {
//noinspection GroovyAssignabilityCheck
executionData.setFrom files(executionData.findAll { it.exists() })
}
}