forked from mobilejazz/harmony-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
95 lines (83 loc) · 2.21 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath(libs.plugins.kotlinGradle.get().toString())
classpath(libs.plugins.androidGradle.get().toString())
}
}
allprojects {
repositories {
mavenLocal()
google()
mavenCentral()
}
}
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.ktlint)
alias(libs.plugins.detekt)
alias(libs.plugins.taskTree)
// version-catalog update configuration
alias(libs.plugins.gradleVersions)
alias(libs.plugins.versionCatalogUpdate)
}
subprojects {
apply {
plugin("org.jlleitschuh.gradle.ktlint")
plugin("io.gitlab.arturbosch.detekt")
}
repositories {
mavenCentral()
}
ktlint {
verbose.set(true)
outputToConsole.set(true)
filter {
exclude { entry ->
entry.file.toString().contains("generated/")
}
}
}
detekt {
config = files("$rootDir/detekt.yml")
}
}
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
reports {
xml.required.set(true) // checkstyle like format mainly for CI integrations
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
//region version-catalog update configuration
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
// https://github.com/ben-manes/gradle-versions-plugin
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
versionCatalogUpdate {
// sort the catalog by key (default is true)
sortByKey.set(false)
keep {
// keep versions without any library or plugin reference
keepUnusedVersions.set(true)
// keep all libraries that aren't used in the project
keepUnusedLibraries.set(false)
// keep all plugins that aren't used in the project
keepUnusedPlugins.set(false)
}
}
//endregion version-catalog update configuration