-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbuild.gradle.kts
71 lines (62 loc) · 2.6 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
plugins {
alias(libs.plugins.versionsBenManes)
alias(libs.plugins.versionCatalogUpdate)
alias(libs.plugins.android.application) apply false // https://youtrack.jetbrains.com/issue/KT-31643/Unable-to-load-class-com.android.build.gradle.BaseExtension-with-Kotlin-plugin-applied-to-root-Gradle-project
alias(libs.plugins.android.library) apply false // see above url
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.kapt) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.hilt) apply false // fun https://github.com/google/dagger/issues/3068
}
//subprojects { parent!!.path.takeIf { it != rootProject.path }?.let { evaluationDependsOn(it) } }
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
subprojects {
buildscript {
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
}
repositories {
google()
mavenCentral()
maven { setUrl("https://androidx.dev/snapshots/builds/7913448/artifacts/repository") }
}
}
val dummyGoogleServices: Configuration by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
attributes {
attribute(Attribute.of("google.services.json", String::class.java), "dummy-json")
}
}
dependencies {
dummyGoogleServices(files(rootProject.file("build-config/dummy-data/dummy-google-services.json")))
}
tasks.withType<DependencyUpdatesTask> {
resolutionStrategy {
componentSelection {
all {
when {
isNonStable(candidate.version) && !isNonStable(currentVersion) -> {
reject("Updating stable to non stable is not allowed")
}
candidate.module == "kotlin-gradle-plugin" && candidate.version != libs.versions.kotlin.get() -> {
reject("Keep Kotlin version on the version specified in libs.versions.toml")
}
// KSP versions are compound versions, starting with the kotlin version
candidate.group == "com.google.devtools.ksp" && !candidate.version.startsWith(libs.versions.kotlin.get()) -> {
reject("KSP needs to stick to Kotlin version")
}
}
}
}
}
}