This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
/
build.gradle.kts
71 lines (64 loc) · 2.19 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
// Without these suppressions version catalog usage here and in other build
// files is marked red by IntelliJ:
// https://youtrack.jetbrains.com/issue/KTIJ-19369.
@Suppress("DSL_SCOPE_VIOLATION",)
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.hilt.plugin) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.secrets) apply false
alias(libs.plugins.gradleDependencyUpdate)
alias(libs.plugins.spotless)
}
subprojects {
apply(plugin = rootProject.libs.plugins.spotless.get().pluginId)
spotless {
val ktlintVersion = "0.46.0"
kotlin {
target("**/*.kt")
targetExclude("**/build/**/*.kt")
licenseHeaderFile(
rootProject.file("spotless/copyright.kt"), "^(package|object|import|interface)"
)
ktlint(ktlintVersion)
}
kotlinGradle {
target("**/*.gradle.kts")
targetExclude("**/build/**/*.kts")
licenseHeaderFile(
rootProject.file("spotless/copyright.kts"),
"(^(?![\\/ ]\\*).*\$)"
)
ktlint(ktlintVersion)
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/**/*.xml")
licenseHeaderFile(
rootProject.file("spotless/copyright.xml"),
"(<[^!?])")
}
}
}
fun String.isNonStable(): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(this)
return isStable.not()
}
tasks.withType<DependencyUpdatesTask> {
resolutionStrategy {
componentSelection {
all {
if (candidate.version.isNonStable() && !currentVersion.isNonStable()) {
reject("Release candidate")
}
}
}
}
}
fun shouldTreatCompilerWarningsAsErrors(): Boolean {
return project.findProperty("warningsAsErrors") == "true"
}