MinimalBible/app-test/build.gradle

97 lines
2.7 KiB
Groovy
Raw Normal View History

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'jacoco'
2014-11-17 16:49:10 -05:00
apply plugin: 'com.github.kt3k.coveralls'
2014-12-05 23:35:59 -05:00
evaluationDependsOn(":app")
2014-11-17 16:49:10 -05:00
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'
2015-02-17 22:44:04 -05:00
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2014-11-17 16:49:10 -05:00
}
}
repositories {
maven {
url 'http://repository.jetbrains.com/repo'
}
2015-02-17 22:44:04 -05:00
mavenCentral()
}
2014-12-05 01:45:21 -05:00
// TODO: Make sure we test against the Debug variant
def androidModule = project(':app')
2014-11-17 14:09:44 -05:00
def firstVariant = androidModule.android.applicationVariants.toList().first()
def testIncludes = [
'**/*Test.class',
'**/*Spek.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.+'
2014-11-21 18:24:24 -05:00
testCompile 'org.mockito:mockito-core:+'
testCompile 'com.jayway.awaitility:awaitility:+'
testCompile 'org.jetbrains.spek:spek:0.1-SNAPSHOT'
2014-11-17 14:09:44 -05:00
testCompile firstVariant.javaCompile.classpath
testCompile firstVariant.javaCompile.outputs.files
testCompile files(androidModule.plugins.findPlugin("com.android.application").getBootClasspath())
2015-02-17 22:44:04 -05:00
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
def buildExcludeTree(path, excludes) {
2015-02-17 22:44:04 -05:00
//noinspection GroovyAssignabilityCheck
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)
}
2014-12-05 23:04:14 -05:00
reports {
xml.enabled true
}
}
2014-11-17 17:11:41 -05:00
coveralls {
sourceDirs = files(androidModule.android.sourceSets.main.java.srcDirs).files.absolutePath
}
tasks.withType(Test) {
2015-02-17 22:44:04 -05:00
scanForTestClasses = true
includes = testIncludes
}