-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathbuild.gradle
149 lines (136 loc) · 5.17 KB
/
build.gradle
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import org.jetbrains.dokka.gradle.DokkaTaskPartial
// https://github.com/gradle/gradle/issues/4848
gradle.startParameter.configureOnDemand = false
buildscript {
apply from: 'gradle/dependencies.gradle'
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath deps.build.gradlePlugins.android
classpath deps.build.gradlePlugins.intellij
classpath deps.build.gradlePlugins.kotlin
classpath deps.build.gradlePlugins.ksp
classpath deps.build.gradlePlugins.dokka
classpath deps.build.gradlePlugins.mavenPublish
classpath deps.build.gradlePlugins.spotless
classpath deps.build.gradlePlugins.shadow
classpath deps.apacheClient
}
}
subprojects {
apply from: rootProject.file('gradle/dependencies.gradle')
repositories {
google()
mavenCentral()
}
configurations.configureEach {
resolutionStrategy.eachDependency {
if (requested.name.startsWith("kotlin-stdlib")) {
useTarget("${requested.group}:${requested.name.replace("jre", "jdk")}:${requested.version}")
} else if (requested.group == "org.jetbrains.kotlin") {
useVersion(deps.versions.kotlin)
} else if (requested.group == "com.google.auto" && requested.name == "auto-common") {
useTarget(deps.autoCommon)
} else if (requested.group == "org.jetbrains.kotlinx" && requested.name == "kotlinx-metadata") {
useTarget(deps.kotlinxMetadata)
} else if (requested.group == "com.google.devtools.ksp") {
useVersion(deps.versions.ksp)
} else if (requested.group == "androidx.room") {
if (requested.name != "room-compiler-processing" && requested.name != "room-compiler-processing-testing") {
useVersion(deps.versions.room)
}
}
}
}
afterEvaluate {
def extraKotlincArgs = [
"-Xjvm-default=all",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.contracts.ExperimentalContracts",
]
if (project.path.startsWith(":compiler")) {
extraKotlincArgs += [
"-opt-in=androidx.room.compiler.processing.ExperimentalProcessingApi"
]
}
boolean isKotlinLibrary = project.plugins.hasPlugin("org.jetbrains.kotlin.jvm") || project.plugins.hasPlugin("org.jetbrains.kotlin.android")
if (isKotlinLibrary) {
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(11))
}
kotlin {
jvmToolchain(11)
}
it.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
freeCompilerArgs += extraKotlincArgs
}
}
}
boolean isAndroidLibraryOrApp = project.plugins.hasPlugin("org.jetbrains.kotlin.android")
if (isAndroidLibraryOrApp) {
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
if (isKotlinLibrary && isAndroidLibraryOrApp) {
android {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
}
if (project.path != ":tests") {
apply plugin: 'com.diffplug.spotless'
spotless {
format 'misc', {
target '*.md', '.gitignore'
trimTrailingWhitespace()
endWithNewline()
}
kotlin {
target "src/**/*.kt"
ktlint(deps.versions.ktlint).editorConfigOverride([
"indent_size": "2",
"continuation_indent_size": "4"
])
suppressLintsFor {
step = 'ktlint'
shortCode = 'standard:function-naming'
}
ktfmt(deps.versions.ktfmt)
licenseHeaderFile rootProject.file('config/spotless/copyright.kt')
trimTrailingWhitespace()
endWithNewline()
}
java {
target "src/**/*.java"
googleJavaFormat(deps.versions.gjf)
licenseHeaderFile rootProject.file('config/spotless/copyright.java')
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
groovyGradle {
target '*.gradle'
trimTrailingWhitespace()
endWithNewline()
}
}
}
apply plugin: 'org.jetbrains.dokka'
if (!project.name.contains("samples") && !project.name.contains("tests")) {
tasks.withType(DokkaTaskPartial).configureEach {
outputDirectory.set(new File(buildDir, "docs/partial"))
moduleName.set(project.property("POM_ARTIFACT_ID").toString())
moduleVersion.set(project.property("VERSION_NAME").toString())
}
}
}