-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
42 lines (38 loc) · 1.55 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
plugins {
id("com.android.application") version "7.4.2" apply false
id("com.android.library") version "7.4.2" apply false
id("org.jetbrains.kotlin.kapt") version "1.8.20" apply false
id("org.jetbrains.kotlin.plugin.serialization") version "1.8.20" apply false
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
id("com.google.dagger.hilt.android") version "2.45" apply false
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
fun Project.getKtlintConfiguration(): Configuration {
return configurations.findByName("ktlint") ?: configurations.create("ktlint") {
val dependency = project.dependencies.create("com.pinterest:ktlint:0.46.1").apply {
attributes.attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
dependencies.add(dependency)
}
}
tasks.register("ktlint", JavaExec::class) {
description = "Check Kotlin code style."
group = "Verification"
classpath = getKtlintConfiguration()
mainClass.set("com.pinterest.ktlint.Main")
args = listOf(
"--reporter=plain",
"--android",
"--reporter=checkstyle,output=${project.buildDir}/reports/checkstyle/ktlint.xml",
"$project.rootDir/**/src/main/**/*.kt"
)
}
tasks.register("ktlintFormat", JavaExec::class) {
description = "Fix Kotlin code style deviations."
group = "formatting"
classpath = getKtlintConfiguration()
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("-F", "$project.rootDir/**/src/main/**/*.kt", "--android")
}