generated from lagoJin/github_template
/
build.gradle.kts
55 lines (50 loc) · 1.76 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
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Dep.Kotlin.version}")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:${Dep.AndroidX.Navigation.version}")
classpath("com.google.dagger:hilt-android-gradle-plugin:${Dep.Hilt.version}")
}
}
plugins {
id("com.diffplug.spotless") version "6.2.2"
}
allprojects {
repositories {
google()
mavenCentral()
}
}
subprojects {
apply(plugin = "com.diffplug.spotless")
val ktlintVer = "0.43.2"
spotless {
kotlin {
target("**/*.kt")
ktlint(ktlintVer).userData(
mapOf("max_line_length" to "100", "disabled_rules" to "import-ordering")
)
}
kotlinGradle {
// same as kotlin, but for .gradle.kts files (defaults to '*.gradle.kts')
target("**/*.gradle.kts")
ktlint(ktlintVer)
}
}
// `spotlessCheck` runs when a build includes `check`, notably during presubmit. In these cases
// we prefer `spotlessCheck` run as early as possible since it fails in seconds. This prevents a
// build from running for several minutes doing other intensive tasks (resource processing, code
// generation, compilation, etc) only to fail on a formatting nit.
// Using `mustRunAfter` avoids creating a task dependency. The order is enforced only if
// `spotlessCheck` is already scheduled to run, so we can still build and launch from the IDE
// while the code is "dirty".
tasks.whenTaskAdded {
if (name == "preBuild") {
mustRunAfter("spotlessCheck")
}
}
}