Exclude the android folder from coverage

This commit is contained in:
Bradlee Speice 2014-11-17 15:41:09 -05:00
parent 9aa83bebe2
commit 5fbbf4ac13

View File

@ -18,11 +18,16 @@ dependencies {
jacocoTestReport { jacocoTestReport {
// Add Android sources/classes for coverage /*
// We can't use additionalClassDirs because of this: Alright, setting up Jacoco the right way is massively confusing.
// http://stackoverflow.com/a/17411305/1454178 Normally, you'd use something like additionalClassDirs to add the folders you need.
// Additionally, for whatever reason, the exclude() call doesn't work However, we want to exclude the android/ folder, and likely will need something else
// inside doFirst {}, please don't move this. in the future. In order to do this though, we need the doFirst block. See SO here:
http://stackoverflow.com/a/17411305/1454178
Additionally, to properly exclude, we need to run that code outside the doFirst block.
No clue why this is, but please don't change this without extensive testing.
*/
def jacocoExcludes = [ def jacocoExcludes = [
"android/**/*" "android/**/*"
] ]
@ -33,12 +38,12 @@ jacocoTestReport {
classDirectories = firstVariant.javaCompile.outputs.files classDirectories = firstVariant.javaCompile.outputs.files
} }
// Back to your regularly scheduled Jacoco
dependsOn test
reports { reports {
xml.enabled true xml.enabled true
csv.enabled false csv.enabled false
html.destination "${buildDir}/jacocoHtml" html.destination "${buildDir}/jacocoHtml"
} }
} }
// Code coverage should depend on the tests
project.jacocoTestReport.dependsOn project.test