Skip to content

Instantly share code, notes, and snippets.

@hernandazevedo
Created March 21, 2019 09:33
Show Gist options
  • Save hernandazevedo/0a80f133fde1b8ab5acf77c2073d8f31 to your computer and use it in GitHub Desktop.
Save hernandazevedo/0a80f133fde1b8ab5acf77c2073d8f31 to your computer and use it in GitHub Desktop.
apply plugin: 'jacoco'
jacoco {
toolVersion = '0.8.2'
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDevDebugUnitTest', 'createDevDebugCoverageReport']) {
group "Reporting"
description "Generate Jacoco coverage reports."
def javaClasses = []
def kotlinClasses = []
def javaSrc = []
def kotlinSrc = []
def execution = []
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
rootProject.subprojects.each { proj ->
javaClasses << fileTree(dir: "$proj.buildDir/intermediates/javac/devDebug", excludes: fileFilter)
kotlinClasses << fileTree(dir: "$proj.buildDir/tmp/kotlin-classes/devDebug", excludes: fileFilter)
javaSrc << "$proj.projectDir/src/main/java"
kotlinSrc << "$proj.projectDir/src/main/kotlin"
execution << fileTree(dir: proj.buildDir,
includes: ['jacoco/testDevDebugUnitTest.exec',
'outputs/code-coverage/connected/**/*.ec'])
}
sourceDirectories = files([javaSrc, kotlinSrc])
classDirectories = files([javaClasses, kotlinClasses])
print execution
executionData = files(execution)
reports {
xml.enabled true
xml.destination file("${rootProject.buildDir}/reports/jacoco/jacocoTestCoverageReport.xml")
html.enabled true
html.destination file("${rootProject.buildDir}/reports/jacoco/html")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment