-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
145 lines (126 loc) · 4.13 KB
/
build.gradle.kts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN
plugins {
base
kotlin("jvm") version Version.kotlin
id(Plugin.ktlint) version Version.ktlintJLLeitschuh
id(Plugin.detekt) version Version.detekt
id(Plugin.koin) version Version.koin
id(Plugin.spotless) version Version.spotless
id(Plugin.gradleVersions) version Version.gradleVersions
}
allprojects {
group = ProjectConfig.group
version = ProjectConfig.version
repositories {
mavenLocal()
jcenter()
maven("https://kotlin.bintray.com/ktor")
maven("https://kotlin.bintray.com/kotlinx")
maven("https://jitpack.io")
}
apply {
plugin("kotlin")
plugin(Plugin.koin)
plugin(Plugin.ktlint)
plugin(Plugin.spotless)
plugin(Plugin.detekt)
}
// Ktlint configuration for sub-projects
ktlint {
// Version of ktlint cmd tool (Ktlint Gradle plugin is just a wrapper for this tool)
version.set(Version.ktlint)
debug.set(true)
verbose.set(true)
android.set(true)
outputToConsole.set(true)
outputColorName.set("BLUE")
ignoreFailures.set(true)
enableExperimentalRules.set(true)
// Uncomment below line and run .\gradlew ktlintCheck to see check ktlint experimental rules
// enableExperimentalRules.set(true)
reporters {
reporter(PLAIN)
reporter(CHECKSTYLE)
}
kotlinScriptAdditionalPaths {
include(fileTree("scripts/"))
}
filter {
exclude("**/generated/**")
include("**/kotlin/**")
}
}
spotless {
java {
target("**/*.java")
googleJavaFormat().aosp()
removeUnusedImports()
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
kotlin {
target("**/*.kt")
// ktlint()
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
format("misc") {
target("**/*.gradle", "**/*.md", "**/.gitignore")
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()
}
kotlinGradle {
target("*.gradle.kts")
ktlint()
}
format("xml") {
target("**/*.xml")
indentWithSpaces()
trimTrailingWhitespace()
endWithNewline()
}
}
detekt {
config = files("$rootDir/detekt.yml")
parallel = true
// By default detekt does not check test source set and gradle specific files, so hey have to be added manually
input = files(
"$rootDir/buildSrc",
"$rootDir/build.gradle.kts",
"$rootDir/settings.gradle.kts",
"src/main/kotlin",
"src/test/kotlin"
)
autoCorrect = true
}
}
tasks.create("stage") {
dependsOn("installDist")
}
tasks {
// Gradle versions plugin configuration
"dependencyUpdates"(com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask::class) {
resolutionStrategy {
componentSelection {
all {
// Do not show pre-release version of library in generated dependency report
val rejected = listOf("alpha", "beta", "rc", "cr", "m", "preview")
.map { qualifier -> Regex("(?i).*[.-]$qualifier[.\\d-]*") }
.any { it.matches(candidate.version) }
if (rejected) {
reject("Release candidate")
}
// kAndroid newest version is 0.8.8 (jcenter), however maven repository contains version 0.8.7 and
// plugin fails to recognize it correctly
if (candidate.group == "com.pawegio.kandroid") {
reject("version ${candidate.version} is broken for ${candidate.group}'")
}
}
}
}
}
}