forked from square/okhttp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
260 lines (230 loc) · 7.76 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import java.net.URL
import kotlinx.validation.ApiValidationExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension
buildscript {
dependencies {
classpath(libs.gradlePlugin.dokka)
classpath(libs.gradlePlugin.kotlin)
classpath(libs.gradlePlugin.androidJunit5)
classpath(libs.gradlePlugin.android)
classpath(libs.gradlePlugin.graal)
classpath(libs.gradlePlugin.bnd)
classpath(libs.gradlePlugin.shadow)
classpath(libs.gradlePlugin.animalsniffer)
classpath(libs.gradlePlugin.errorprone)
classpath(libs.gradlePlugin.spotless)
classpath(libs.gradlePlugin.mavenPublish)
classpath(libs.gradlePlugin.binaryCompatibilityValidator)
}
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
}
allprojects {
group = "com.squareup.okhttp3"
version = "5.0.0-SNAPSHOT"
repositories {
mavenCentral()
google()
}
tasks.create("downloadDependencies") {
description = "Download all dependencies to the Gradle cache"
doLast {
for (configuration in configurations) {
if (configuration.isCanBeResolved) {
configuration.files
}
}
}
}
normalization {
runtimeClasspath {
metaInf {
ignoreAttribute("Bnd-LastModified")
}
}
}
}
/** Configure building for Java+Kotlin projects. */
subprojects {
val project = this@subprojects
if (project.name == "okhttp-bom") return@subprojects
if (project.name == "okhttp-android") return@subprojects
if (project.name == "android-test") return@subprojects
if (project.name == "regression-test") return@subprojects
apply(plugin = "checkstyle")
apply(plugin = "ru.vyarus.animalsniffer")
apply(plugin = "biz.aQute.bnd.builder")
tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.toString()
}
configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
tasks.withType<Checkstyle>().configureEach {
exclude("**/CipherSuite.java")
}
val checkstyleConfig: Configuration by configurations.creating
dependencies {
checkstyleConfig(rootProject.libs.checkStyle) {
isTransitive = false
}
}
configure<CheckstyleExtension> {
config = resources.text.fromArchiveEntry(checkstyleConfig, "google_checks.xml")
toolVersion = rootProject.libs.versions.checkStyle.get()
sourceSets = listOf(project.sourceSets["main"])
}
// Animal Sniffer confirms we generally don't use APIs not on Java 8.
configure<AnimalSnifferExtension> {
annotation = "okhttp3.internal.SuppressSignatureCheck"
sourceSets = listOf(project.sourceSets["main"])
}
val signature: Configuration by configurations.getting
dependencies {
signature(rootProject.libs.signature.android.apilevel21)
signature(rootProject.libs.codehaus.signature.java18)
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs = listOf(
"-Xjvm-default=compatibility",
"-Xopt-in=kotlin.RequiresOptIn"
)
}
}
val platform = System.getProperty("okhttp.platform", "jdk9")
val testJavaVersion = System.getProperty("test.java.version", "11").toInt()
val testRuntimeOnly: Configuration by configurations.getting
dependencies {
testRuntimeOnly(rootProject.libs.junit.jupiter.engine)
testRuntimeOnly(rootProject.libs.junit.vintage.engine)
}
tasks.withType<Test> {
useJUnitPlatform()
jvmArgs = jvmArgs!! + listOf(
"-Dokhttp.platform=$platform",
"-XX:+HeapDumpOnOutOfMemoryError"
)
val javaToolchains = project.extensions.getByType<JavaToolchainService>()
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(testJavaVersion))
})
maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
testLogging {
exceptionFormat = TestExceptionFormat.FULL
}
systemProperty("okhttp.platform", platform)
systemProperty("junit.jupiter.extensions.autodetection.enabled", "true")
}
if (platform == "jdk8alpn") {
// Add alpn-boot on Java 8 so we can use HTTP/2 without a stable API.
val alpnBootVersion = alpnBootVersion()
if (alpnBootVersion != null) {
val alpnBootJar = configurations.detachedConfiguration(
dependencies.create("org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion")
).singleFile
tasks.withType<Test> {
jvmArgs = jvmArgs!! + listOf("-Xbootclasspath/p:${alpnBootJar}")
}
}
} else if (platform == "conscrypt") {
dependencies {
testRuntimeOnly(rootProject.libs.conscrypt.openjdk)
}
} else if (platform == "openjsse") {
dependencies {
testRuntimeOnly(rootProject.libs.openjsse)
}
}
tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}
}
/** Configure publishing and signing for published Java and JavaPlatform subprojects. */
subprojects {
tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
skipDeprecated.set(true)
jdkVersion.set(8)
perPackageOption {
matchingRegex.set("okhttp3\\.internal.*")
suppress.set(true)
}
perPackageOption {
matchingRegex.set("mockwebserver3\\.internal.*")
suppress.set(true)
}
if (project.file("Module.md").exists()) {
includes.from(project.file("Module.md"))
}
externalDocumentationLink {
url.set(URL("https://square.github.io/okio/2.x/okio/"))
packageListUrl.set(URL("https://square.github.io/okio/2.x/okio/package-list"))
}
}
if (name == "dokkaGfm") {
outputDirectory.set(file("${rootDir}/docs/4.x"))
}
}
plugins.withId("com.vanniktech.maven.publish.base") {
configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()
pom {
name.set(project.name)
description.set("Square’s meticulous HTTP client for Java and Kotlin.")
url.set("https://square.github.io/okhttp/")
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 {
connection.set("scm:git:https://github.com/square/okhttp.git")
developerConnection.set("scm:git:ssh://[email protected]/square/okhttp.git")
url.set("https://github.com/square/okhttp")
}
developers {
developer {
name.set("Square, Inc.")
}
}
}
}
}
plugins.withId("binary-compatibility-validator") {
configure<ApiValidationExtension> {
ignoredPackages += "okhttp3.logging.internal"
ignoredPackages += "mockwebserver3.internal"
ignoredPackages += "okhttp3.internal"
ignoredPackages += "mockwebserver3.junit5.internal"
ignoredPackages += "okhttp3.brotli.internal"
ignoredPackages += "okhttp3.sse.internal"
ignoredPackages += "okhttp3.tls.internal"
}
}
}
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}
// Fix until 1.6.20 https://youtrack.jetbrains.com/issue/KT-49109
rootProject.plugins.withType(NodeJsRootPlugin::class.java) {
rootProject.the<NodeJsRootExtension>().nodeVersion = "16.13.0"
}