Skip to content

Instantly share code, notes, and snippets.

@Aidan128
Last active Mar 6, 2022
Embed
What would you like to do?
jacoco gradle script for inclusion in module-level build.gradle
apply plugin: 'jacoco'
jacoco {
toolVersion '0.8.7'
}
task jacocoUnifiedReport(type: JacocoReport) {
reports {
xml.enabled = true
html.enabled = true
}
def sourceDirectories = subprojects.collect { subproject ->
"${subproject.projectDir}/src/main/java"
}
def classDirectories = subprojects.collect { subproject ->
["${subproject.buildDir}/intermediates/javac/debug", "${subproject.buildDir}/tmp/kotlin-classes/debug"]
}.flatten()
def classFiles = classDirectories.collect { directory ->
def excludesFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
fileTree(dir: file(directory), excludes: excludesFilter)
}
def executionDirectories = subprojects.collect { subproject ->
["${subproject.buildDir}/outputs/code_coverage", "${subproject.buildDir}/jacoco"]
}.flatten()
def executionFiles = executionDirectories.collect { directory ->
def includesFilter = ['*.ec', '*.exec']
fileTree(dir: file(directory), includes: includesFilter)
}
getSourceDirectories().setFrom(sourceDirectories)
getClassDirectories().setFrom(classFiles)
getExecutionData().setFrom(executionFiles)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment