-
Notifications
You must be signed in to change notification settings - Fork 761
/
build.gradle.kts
162 lines (152 loc) · 4.52 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
import com.diffplug.gradle.spotless.JavaExtension
import com.google.devtools.ksp.gradle.KspTaskJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI
buildscript {
dependencies {
val kotlinVersion =
System.getenv("MOSHI_KOTLIN_VERSION")
?: libs.versions.kotlin.get()
val kspVersion =
System.getenv("MOSHI_KSP_VERSION")
?: libs.versions.ksp.get()
classpath(kotlin("gradle-plugin", version = kotlinVersion))
classpath("com.google.devtools.ksp:symbol-processing-gradle-plugin:$kspVersion")
// https://github.com/melix/japicmp-gradle-plugin/issues/36
classpath("com.google.guava:guava:33.3.1-jre")
}
}
plugins {
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.spotless)
alias(libs.plugins.japicmp) apply false
alias(libs.plugins.ksp) apply false
}
allprojects {
group = "com.squareup.moshi"
version = "2.0.0-SNAPSHOT"
repositories {
mavenCentral()
}
}
spotless {
format("misc") {
target("*.md", ".gitignore")
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
val configureCommonJavaFormat: JavaExtension.() -> Unit = {
googleJavaFormat(libs.googleJavaFormat.get().version)
}
java {
configureCommonJavaFormat()
target("**/*.java")
targetExclude("**/build/**")
}
kotlin {
ktlint(libs.ktlint.get().version).editorConfigOverride(
mapOf(
"ktlint_standard_filename" to "disabled",
// Making something an expression body should be a choice around readability.
"ktlint_standard_function-expression-body" to "disabled",
),
)
target("**/*.kt")
trimTrailingWhitespace()
endWithNewline()
targetExclude("**/Dependencies.kt", "**/build/**")
}
kotlinGradle {
ktlint(libs.ktlint.get().version)
target("**/*.gradle.kts")
trimTrailingWhitespace()
endWithNewline()
}
}
subprojects {
// Apply with "java" instead of just "java-library" so kotlin projects get it too
pluginManager.withPlugin("java") {
configure<JavaPluginExtension> {
toolchain {
languageVersion.set(libs.versions.jdk.map(JavaLanguageVersion::of))
}
}
if (project.name != "records-tests") {
tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}
}
}
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
tasks.withType<KotlinCompile>().configureEach {
val isKsp1Task = this is KspTaskJvm
compilerOptions {
progressiveMode.set(!isKsp1Task)
jvmTarget.set(JvmTarget.fromTarget(libs.versions.jvmTarget.get()))
}
}
configure<KotlinProjectExtension> {
if (project.name != "examples") {
explicitApi()
}
}
}
}
allprojects {
tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
skipDeprecated.set(true)
jdkVersion.set(8)
perPackageOption {
matchingRegex.set("com\\.squareup.moshi\\.internal.*")
suppress.set(true)
}
}
if (name == "dokkaHtml") {
outputDirectory.set(rootDir.resolve("docs/1.x"))
dokkaSourceSets.configureEach {
skipDeprecated.set(true)
externalDocumentationLink {
url.set(URI("https://square.github.io/okio/2.x/okio/").toURL())
}
}
}
}
plugins.withId("com.vanniktech.maven.publish.base") {
configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()
pom {
description.set("A modern JSON API for Android and Java")
name.set(project.name)
url.set("https://github.com/square/moshi/")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
scm {
url.set("https://github.com/square/moshi/")
connection.set("scm:git:git://github.com/square/moshi.git")
developerConnection.set("scm:git:ssh://[email protected]/square/moshi.git")
}
developers {
developer {
id.set("square")
name.set("Square, Inc.")
}
}
}
}
}
}