MinimalBible/app-test/build.gradle

93 lines
2.4 KiB
Groovy

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
evaluationDependsOn(":app")
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*',
'**/BookAdapter$ChapterInfo*',
'**/*$$*' // Dagger/Butterknife
]
dependencies {
compile androidModule
testCompile 'junit:junit:4.+'
testCompile 'org.robolectric:robolectric:2.+'
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<String>()
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
// For whatever reason, firstVariant.javaCompile.exclude(jacocoExcludes) doesn't work...
classDirectories = outputTree
sourceDirectories = files(androidModule.android.sourceSets.main.java.srcDirs)
}
reports {
xml.enabled true
}
}
coveralls {
sourceDirs = files(androidModule.android.sourceSets.main.java.srcDirs).files.absolutePath
}
tasks.withType(Test) {
scanForTestClasses = false
includes = testIncludes
}