Created
February 10, 2018 04:37
-
-
Save jaredsburrows/555fb1ccdf656c14aedb11341f08ece9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply { | |
plugin("com.android.application") | |
plugin("jacoco") | |
plugin("com.github.kt3k.coveralls") | |
plugin("io.gitlab.arturbosch.detekt") | |
} | |
// Creates tasks based on the application build variant (productFlavor + buildType = variant) | |
android.applicationVariants.all { variant -> | |
def variantName = variant.name.capitalize() | |
def autoGenerated = ['**/R.class', | |
'**/R$*.class', | |
'**/BuildConfig.*', | |
'**/*ViewBinding*.*', | |
'**/BR.class', | |
'**/databinding/**', | |
'**/Companion/**', | |
'**/*Initializer*.*', | |
'**/*Test*.*', | |
'**/*$Lambda$*.*', | |
'**/*Module.*', | |
'**/*Dagger*.*', | |
'**/*MembersInjector*.*', | |
'**/*_Provide*Factory*.*'] | |
/** | |
* Generates Jacoco coverage reports based off the unit tests. | |
*/ | |
task("jacoco${variantName}Report", type: JacocoReport, dependsOn: "test${variantName}UnitTest") { | |
group "Reporting" | |
description "Generate ${variantName} Jacoco coverage reports." | |
reports { | |
xml.enabled = true | |
html.enabled = true | |
} | |
// variant.javaCompile.source does not work | |
// traverses from starting point | |
sourceDirectories = files(android.sourceSets.main.java.srcDirs + android.sourceSets.main.kotlin.srcDirs) | |
classDirectories = fileTree(dir: "$buildDir/intermediates/classes/debug", excludes: autoGenerated) | |
executionData = fileTree(dir: "$buildDir", includes: [ | |
"jacoco/test${variantName}UnitTest.exec", // unit test - test${variantName}UnitTest | |
"outputs/code-coverage/connected/*coverage.ec" // android test - create${variantName}CoverageReport | |
]) | |
} | |
} | |
detekt { | |
version = "1.0.0.RC4-3" | |
profile("main") { | |
input = "$projectDir/src/main/kotlin" | |
config = rootProject.file("${project.rootDir}/config/detekt/detekt.yml") | |
filters = ".*Test.*,.*/resources/.*,.*/tmp/.*" | |
} | |
} | |
coveralls { | |
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoDebugReport/jacocoDebugReport.xml" | |
} | |
afterEvaluate { | |
tasks.findByName("check").dependsOn("detektCheck") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment