-
Notifications
You must be signed in to change notification settings - Fork 801
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
182 lines (170 loc) · 5.57 KB
/
build.gradle.kts
File metadata and controls
182 lines (170 loc) · 5.57 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import com.diffplug.gradle.spotless.JavaExtension
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import java.net.URI
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
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")
}
}
plugins {
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.dokka)
alias(libs.plugins.spotless)
alias(libs.plugins.japicmp) apply false
alias(libs.plugins.ksp) apply false
}
allprojects {
group = "com.squareup.moshi"
version = project.property("VERSION_NAME") as String
repositories { mavenCentral() }
}
spotless {
format("misc") {
target("*.md", ".gitignore")
trimTrailingWhitespace()
leadingTabsToSpaces(2)
endWithNewline()
}
val configureCommonJavaFormat: JavaExtension.() -> Unit = {
googleJavaFormat(libs.googleJavaFormat.get().version)
}
java {
configureCommonJavaFormat()
target("**/*.java")
targetExclude("**/build/**")
}
kotlin {
ktfmt(libs.ktfmt.get().version).googleStyle()
target("**/*.kt")
trimTrailingWhitespace()
endWithNewline()
targetExclude("**/Dependencies.kt", "**/build/**")
}
kotlinGradle {
ktfmt(libs.ktfmt.get().version).googleStyle()
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 {
compilerOptions {
progressiveMode.set(true)
jvmTarget.set(JvmTarget.fromTarget(libs.versions.jvmTarget.get()))
}
}
configure<KotlinProjectExtension> {
if (project.name != "examples") {
explicitApi()
}
}
}
}
dependencies {
dokka(project(":moshi"))
dokka(project(":moshi-adapters"))
dokka(project(":moshi-kotlin"))
dokka(project(":moshi-kotlin-codegen"))
}
dokka { dokkaPublications.html { outputDirectory.set(layout.projectDirectory.dir("docs/2.x")) } }
subprojects {
plugins.withId("org.jetbrains.dokka") {
configure<DokkaExtension> {
basePublicationsDirectory.set(layout.buildDirectory.dir("dokkaDir"))
dokkaSourceSets.configureEach {
skipDeprecated.set(true)
reportUndocumented.set(true)
jdkVersion.set(8)
perPackageOption {
matchingRegex.set("com\\.squareup\\.moshi\\.internal.*")
suppress.set(true)
}
externalDocumentationLinks.register("Okio") {
packageListUrl("https://square.github.io/okio/3.x/okio/okio/package-list")
url("https://square.github.io/okio/3.x/okio")
}
sourceLink {
localDirectory.set(layout.projectDirectory.dir("src"))
val relPath =
rootProject.isolated.projectDirectory.asFile.toPath().relativize(projectDir.toPath())
remoteUrl("https://github.com/square/moshi/tree/main/$relPath/src")
remoteLineSuffix.set("#L")
}
}
}
}
plugins.withId("com.vanniktech.maven.publish") {
configure<PublishingExtension> {
repositories {
/*
* Want to push to an internal repository for testing?
* Set the following properties in ~/.gradle/gradle.properties.
*
* internalUrl=YOUR_INTERNAL_URL
* internalUsername=YOUR_USERNAME
* internalPassword=YOUR_PASSWORD
*
* Then run the following command to publish a new internal release:
*
* ./gradlew publishAllPublicationsToInternalRepository -DRELEASE_SIGNING_ENABLED=false
*/
val internalUrl = providers.gradleProperty("internalUrl").orNull
if (internalUrl != null) {
maven {
name = "internal"
url = URI(internalUrl)
credentials {
username = providers.gradleProperty("internalUsername").get()
password = providers.gradleProperty("internalPassword").get()
}
}
}
}
}
configure<MavenPublishBaseExtension> {
publishToMavenCentral(automaticRelease = true)
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://git@github.com/square/moshi.git")
}
developers {
developer {
id.set("square")
name.set("Square, Inc.")
}
}
}
}
}
}