-
Notifications
You must be signed in to change notification settings - Fork 43
/
build.gradle
116 lines (106 loc) · 4.19 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
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.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) {
it.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
freeCompilerArgs += extraKotlincArgs
}
}
}
}
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).userData(['indent_size': '2', 'continuation_indent_size': '2'])
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())
}
}
}