-
Notifications
You must be signed in to change notification settings - Fork 7.3k
/
build.gradle.kts
90 lines (76 loc) · 2.68 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins {
id("com.android.application") version "8.7.2" apply false
id("com.android.library") version "8.7.2" apply false
id("org.jetbrains.kotlin.android") version "2.0.21" apply false
id("com.google.gms.google-services") version "4.4.2" apply false
id("com.google.firebase.crashlytics") version "3.0.2" apply false
id("com.google.firebase.firebase-perf") version "1.4.2" apply false
id("androidx.navigation.safeargs") version "2.8.4" apply false
id("com.github.ben-manes.versions") version "0.51.0" apply true
id("org.jetbrains.kotlin.plugin.compose") version "2.0.21" apply false
}
allprojects {
repositories {
google()
mavenLocal()
mavenCentral()
}
}
val ktlint by configurations.creating
dependencies {
ktlint("com.pinterest:ktlint:0.49.1") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
}
tasks.register<JavaExec>("ktlintCheck") {
val outputDir = "${project.buildDir}/reports/ktlint/"
val inputFiles = project.fileTree("src").include("**/*.kt")
val outputFile = "${outputDir}ktlint-checkstyle-report.xml"
// See: https://medium.com/@vanniktech/making-your-gradle-tasks-incremental-7f26e4ef09c3
inputs.files(inputFiles)
outputs.file(outputFile)
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Check Kotlin code style"
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
args(
"--format",
"--code-style=android_studio",
"--reporter=plain",
"--reporter=checkstyle,output=${outputFile}",
"**/*.kt"
)
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
}
fun notFromFirebase(candidate: ModuleComponentIdentifier): Boolean {
return candidate.group != "com.google.firebase"
}
fun isNonStable(candidate: ModuleComponentIdentifier): Boolean {
return listOf("alpha", "beta", "rc", "snapshot", "-m", "final").any { keyword ->
keyword in candidate.version.lowercase()
}
}
fun isBlockListed(candidate: ModuleComponentIdentifier): Boolean {
return listOf(
"androidx.browser:browser",
"com.facebook.android",
"com.google.guava",
"com.github.bumptech.glide",
"com.google.android.gms"
).any { keyword ->
keyword in candidate.toString().lowercase()
}
}
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
(isNonStable(candidate) && notFromFirebase(candidate)) || isBlockListed(candidate)
}
}
tasks {
register("clean", Delete::class) {
delete(rootProject.buildDir)
}
}