-
Notifications
You must be signed in to change notification settings - Fork 8
/
detekt-init.groovy
41 lines (39 loc) · 1.18 KB
/
detekt-init.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import org.gradle.api.Project
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.gitlab.arturbosch.detekt:detekt-cli:1.0.0.RC8'
}
}
ext.DETEKT = 'detekt'
gradle.projectsEvaluated {
ext.applyDetekt = {
if (project.hasProperty('android')) {
if (!project.hasProperty(DETEKT)) {
addDetektTask project
}
}
}
if (rootProject.subprojects.isEmpty()) {
rootProject applyDetekt
} else {
rootProject.subprojects applyDetekt
}
}
//Detekt task
void addDetektTask(final Project project) {
ext.source = ['main', 'androidTest', 'test'].collect {
project.android.sourceSets.findByName(it)
}.find { null != it }.collect { it.java.srcDirs }
project.tasks.create([name:DETEKT, type:JavaExec, group:'verification']) {
args '--input', 'src/main/java'
args '--output', "${project.reportsDir.path}/$DETEKT"
classpath files(buildscript.scriptClassPath.asFiles)
description 'Kotlin static checker'
ignoreExitValue true
main 'io.gitlab.arturbosch.detekt.cli.Main'
}
project.check.dependsOn project.tasks[DETEKT]
}