2014-11-17 13:35:15 -05:00
|
|
|
apply plugin: 'java'
|
|
|
|
apply plugin: 'kotlin'
|
|
|
|
apply plugin: 'jacoco'
|
|
|
|
|
|
|
|
def androidModule = project(':app')
|
2014-11-17 14:09:44 -05:00
|
|
|
def firstVariant = androidModule.android.applicationVariants.toList().first()
|
2014-11-17 13:35:15 -05:00
|
|
|
|
|
|
|
dependencies {
|
|
|
|
compile androidModule
|
|
|
|
|
2014-11-17 14:09:44 -05:00
|
|
|
testCompile firstVariant.javaCompile.classpath
|
|
|
|
testCompile firstVariant.javaCompile.outputs.files
|
2014-11-17 13:35:15 -05:00
|
|
|
testCompile files(androidModule.plugins.findPlugin("com.android.application").getBootClasspath())
|
|
|
|
|
|
|
|
testCompile 'junit:junit:4.+'
|
2014-11-17 14:09:44 -05:00
|
|
|
testCompile 'org.robolectric:robolectric:+'
|
2014-11-17 13:35:15 -05:00
|
|
|
}
|
|
|
|
|
2014-11-17 15:36:42 -05:00
|
|
|
|
2014-11-17 13:35:15 -05:00
|
|
|
jacocoTestReport {
|
|
|
|
// Add Android sources/classes for coverage
|
2014-11-17 15:36:42 -05:00
|
|
|
// We can't use additionalClassDirs because of this:
|
|
|
|
// http://stackoverflow.com/a/17411305/1454178
|
|
|
|
// Additionally, for whatever reason, the exclude() call doesn't work
|
|
|
|
// inside doFirst {}, please don't move this.
|
|
|
|
def jacocoExcludes = [
|
|
|
|
"android/**/*"
|
|
|
|
]
|
|
|
|
firstVariant.javaCompile.exclude(jacocoExcludes).outputs.files
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
sourceDirectories = files(androidModule.android.sourceSets.main.java.srcDirs)
|
|
|
|
classDirectories = firstVariant.javaCompile.outputs.files
|
|
|
|
}
|
2014-11-17 13:35:15 -05:00
|
|
|
|
|
|
|
reports {
|
|
|
|
xml.enabled true
|
|
|
|
csv.enabled false
|
|
|
|
html.destination "${buildDir}/jacocoHtml"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Code coverage should depend on the tests
|
|
|
|
project.jacocoTestReport.dependsOn project.test
|