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'
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:1.0.2'
|
|
|
|
}
|
|
|
|
}
|
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-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
|
|
|
}
|
|
|
|
|
|
|
|
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-11-17 15:36:42 -05:00
|
|
|
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
|
|
|
|
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
|
|
|
|
}
|