2014-11-17 13:35:15 -05:00
|
|
|
apply plugin: 'java'
|
|
|
|
apply plugin: 'kotlin'
|
|
|
|
apply plugin: 'jacoco'
|
2014-11-17 16:49:10 -05:00
|
|
|
apply plugin: 'com.github.kt3k.coveralls'
|
|
|
|
|
2014-11-20 00:52:42 -05:00
|
|
|
evaluationDependsOn(":app")
|
|
|
|
|
2014-11-17 16:49:10 -05:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2014-11-17 21:58:23 -05:00
|
|
|
// Version lock for https://github.com/kt3k/coveralls-gradle-plugin/issues/27
|
|
|
|
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1x'
|
2014-11-17 16:49:10 -05:00
|
|
|
}
|
|
|
|
}
|
2014-11-17 13:35:15 -05:00
|
|
|
|
2014-11-20 23:58:26 -05:00
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
url 'http://repository.jetbrains.com/repo'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-21 18:01:35 -05:00
|
|
|
test {
|
|
|
|
testLogging {
|
|
|
|
exceptionFormat = 'full'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-17 13:35:15 -05:00
|
|
|
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-20 00:52:42 -05:00
|
|
|
testCompile 'junit:junit:4.+'
|
|
|
|
testCompile 'org.robolectric:robolectric:+'
|
2014-11-21 18:24:24 -05:00
|
|
|
testCompile 'org.mockito:mockito-core:+'
|
2014-11-20 00:52:42 -05:00
|
|
|
testCompile 'com.jayway.awaitility:awaitility:+'
|
2014-11-20 23:58:26 -05:00
|
|
|
testCompile 'org.jetbrains.spek:spek:+'
|
2014-11-20 00:52:42 -05:00
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
|
|
|
|
jacocoTestReport {
|
2014-11-17 15:41:09 -05:00
|
|
|
/*
|
|
|
|
Alright, setting up Jacoco the right way is massively confusing.
|
|
|
|
Normally, you'd use something like additionalClassDirs to add the folders you need.
|
|
|
|
However, we want to exclude the android/ folder, and likely will need something else
|
|
|
|
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.
|
2014-12-01 23:56:55 -05:00
|
|
|
|
|
|
|
Finally, because we actually exclude these files from the output, they are removed
|
|
|
|
from the actual classpath, meaning no test classes can reference any of the below.
|
|
|
|
Otherwise, I'd remove com/toddddavies/** as well
|
2014-11-17 15:41:09 -05:00
|
|
|
*/
|
2014-11-17 15:36:42 -05:00
|
|
|
def jacocoExcludes = [
|
2014-12-01 23:56:55 -05:00
|
|
|
"android/**/*",
|
|
|
|
"com/cmwmobile/**"
|
2014-11-17 15:36:42 -05:00
|
|
|
]
|
|
|
|
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
|
|
|
|
2014-11-17 15:41:09 -05:00
|
|
|
// Back to your regularly scheduled Jacoco
|
2014-11-17 13:35:15 -05:00
|
|
|
reports {
|
|
|
|
xml.enabled true
|
|
|
|
csv.enabled false
|
|
|
|
html.destination "${buildDir}/jacocoHtml"
|
|
|
|
}
|
|
|
|
}
|
2014-11-17 17:11:41 -05:00
|
|
|
|
|
|
|
coveralls {
|
|
|
|
sourceDirs = files(androidModule.android.sourceSets.main.java.srcDirs).files.absolutePath
|
|
|
|
}
|
2014-11-20 00:52:42 -05:00
|
|
|
|
|
|
|
tasks.withType(Test) {
|
|
|
|
scanForTestClasses = false
|
|
|
|
include "**/*Test.class"
|
|
|
|
}
|