forked from google/fhir-app-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
72 lines (69 loc) · 2.45 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath("com.android.tools.build:gradle:8.1.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")
classpath("com.google.gms:google-services:4.3.15")
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.6.0")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
gradlePluginPortal()
}
configureSpotless()
}
fun Project.configureSpotless() {
val ktlintVersion = "0.41.0"
val ktlintOptions = mapOf("indent_size" to "2", "continuation_indent_size" to "2")
apply(plugin = "com.diffplug.spotless")
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
ratchetFrom = "origin/main"
kotlin {
target("**/*.kt")
targetExclude("**/build/")
targetExclude("**/*_Generated.kt")
ktlint(ktlintVersion).userData(ktlintOptions)
ktfmt().googleStyle()
licenseHeaderFile(
"${project.rootProject.projectDir}/license-header.txt",
"package|import|class|object|sealed|open|interface|abstract "
// It is necessary to tell spotless the top level of a file in order to apply config to it
// See: https://github.com/diffplug/spotless/issues/135
)
}
kotlinGradle {
target("*.gradle.kts")
ktlint(ktlintVersion).userData(ktlintOptions)
ktfmt().googleStyle()
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/", ".idea/")
prettier(mapOf("prettier" to "2.0.5", "@prettier/plugin-xml" to "0.13.0"))
.config(mapOf("parser" to "xml", "tabWidth" to 4))
}
// Creates one off SpotlessApply task for generated files
com.diffplug.gradle.spotless.KotlinExtension(this).apply {
target("**/*_Generated.kt")
ktlint(ktlintVersion).userData(ktlintOptions)
ktfmt().googleStyle()
licenseHeaderFile(
"${project.rootProject.projectDir}/license-header.txt",
"package|import|class|object|sealed|open|interface|abstract "
)
createIndependentApplyTask("spotlessGenerated")
}
}
}