apply plugin: 'java' apply plugin: 'kotlin' apply plugin: 'jacoco' apply plugin: 'com.github.kt3k.coveralls' //evaluationDependsOn(":app:compileDebugJava") buildscript { repositories { mavenCentral() } dependencies { // Version lock for https://github.com/kt3k/coveralls-gradle-plugin/issues/27 classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1x' } } repositories { maven { url 'http://repository.jetbrains.com/repo' } } // TODO: Make sure we test against the Debug variant def androidModule = project(':app') def firstVariant = androidModule.android.applicationVariants.toList().first() // TODO: Not yet including Spek tests, fix that. def testIncludes = [ '**/*Test.class' ] def jacocoExcludes = [ 'android/**', 'com/todddavies/**', 'com/cmwmobile/**', 'org/bspeice/minimalbible/R*', '**/*$$*' ] dependencies { compile androidModule testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:+' testCompile 'org.mockito:mockito-core:+' testCompile 'com.jayway.awaitility:awaitility:+' testCompile 'org.jetbrains.spek:spek:+' testCompile firstVariant.javaCompile.classpath testCompile firstVariant.javaCompile.outputs.files testCompile files(androidModule.plugins.findPlugin("com.android.application").getBootClasspath()) } def buildExcludeTree(path, excludes) { def tree = fileTree(path).exclude(excludes) tree } jacocoTestReport { doFirst { // First we build a list of our base directories def fileList = new ArrayList() def outputsList = firstVariant.javaCompile.outputs.files outputsList.each { fileList.add(it.absolutePath.toString()) } // And build a fileTree from those def outputTree = fileList.inject { tree1, tree2 -> buildExcludeTree(tree1, jacocoExcludes) + buildExcludeTree(tree2, jacocoExcludes) } // And finally tell Jacoco to only include said files in the report classDirectories = outputTree } } tasks.withType(Test) { scanForTestClasses = false includes = testIncludes }