forked from square/okhttp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
423 lines (380 loc) · 12.8 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
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
buildscript {
ext.versions = [
'animalSniffer': '1.19',
'assertj': '3.15.0',
'bouncycastle': '1.67',
'brotli': '0.1.2',
'checkstyle': '8.28',
'conscrypt': '2.5.1',
'corretto': '1.3.1',
'findbugs': '3.0.2',
'guava': '28.2-jre',
'java': '1.8',
'jnrUnixsocket': '0.28',
'jsoup': '1.13.1',
'junit': '4.13',
'junit5': '5.7.0',
'kotlin': '1.4.10',
'moshi': '1.11.0',
'okio': '2.9.0',
'ktlint': '0.38.0',
'picocli': '4.5.1',
'openjsse': '1.1.0',
'bnd': '5.1.2',
'equinox': '3.16.0'
]
ext.deps = [
'picocli': "info.picocli:picocli:${versions.picocli}",
'android': "org.robolectric:android-all:11-robolectric-6757853",
'animalSniffer': "org.codehaus.mojo:animal-sniffer-annotations:${versions.animalSniffer}",
'assertj': "org.assertj:assertj-core:${versions.assertj}",
'bouncycastle': "org.bouncycastle:bcprov-jdk15to18:${versions.bouncycastle}",
'bouncycastlepkix': "org.bouncycastle:bcpkix-jdk15to18:${versions.bouncycastle}",
'bouncycastletls': "org.bouncycastle:bctls-jdk15to18:${versions.bouncycastle}",
'brotli': "org.brotli:dec:${versions.brotli}",
'conscrypt': "org.conscrypt:conscrypt-openjdk-uber:${versions.conscrypt}",
'corretto': "software.amazon.cryptools:AmazonCorrettoCryptoProvider:${versions.corretto}:linux-x86_64",
'guava': "com.google.guava:guava:${versions.guava}",
'hamcrest': 'org.hamcrest:hamcrest-library:2.1',
'jnrUnixsocket': "com.github.jnr:jnr-unixsocket:${versions.jnrUnixsocket}",
'jsoup': "org.jsoup:jsoup:${versions.jsoup}",
'jsr305': "com.google.code.findbugs:jsr305:${versions.findbugs}",
'junit': "junit:junit:${versions.junit}",
'junit5Api': "org.junit.jupiter:junit-jupiter-api:${versions.junit5}",
'junit5JupiterEngine': "org.junit.jupiter:junit-jupiter-engine:${versions.junit5}",
'junit5JupiterParams': "org.junit.jupiter:junit-jupiter-params:${versions.junit5}",
'junit5VintageEngine': "org.junit.vintage:junit-vintage-engine:${versions.junit5}",
'junitPlatformConsole': "org.junit.platform:junit-platform-console:1.7.0",
'kotlinStdlib': "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}",
'moshi': "com.squareup.moshi:moshi:${versions.moshi}",
'moshiKotlin': "com.squareup.moshi:moshi-kotlin-codegen:${versions.moshi}",
'okio': "com.squareup.okio:okio:${versions.okio}",
'openjsse': "org.openjsse:openjsse:${versions.openjsse}",
'bnd': "biz.aQute.bnd:biz.aQute.bnd.gradle:${versions.bnd}",
'bndResolve': "biz.aQute.bnd:biz.aQute.resolve:${versions.bnd}",
'equinox': "org.eclipse.platform:org.eclipse.osgi:${versions.equinox}",
'kotlinStdlibOsgi': "org.jetbrains.kotlin:kotlin-osgi-bundle:${versions.kotlin}"
]
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.10.1"
classpath "com.android.tools.build:gradle:4.0.2"
classpath deps.bnd
}
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
}
plugins {
id "ru.vyarus.animalsniffer" version "1.5.1"
id "com.github.johnrengelman.shadow" version "5.2.0"
id "me.champeau.gradle.japicmp" version "0.2.9"
id "com.diffplug.spotless" version "5.1.2"
id "net.ltgt.errorprone" version "1.2.1"
}
/** Returns the artifact ID for the project, or null if it is not published. */
ext.publishedArtifactId = { project ->
if (project.name == 'okhttp-logging-interceptor') {
return 'logging-interceptor'
} else if (project.name == 'mockwebserver') {
return 'mockwebserver3'
} else if (project.name == 'mockwebserver-junit4') {
return 'mockwebserver3-junit4'
} else if (project.name == 'mockwebserver-junit5') {
return 'mockwebserver3-junit5'
} else if (project.name == 'mockwebserver-deprecated') {
return 'mockwebserver'
} else if (project.name == 'okcurl'
|| project.name == 'okhttp'
|| project.name == 'okhttp-bom'
|| project.name == 'okhttp-brotli'
|| project.name == 'okhttp-dnsoverhttps'
|| project.name == 'okhttp-sse'
|| project.name == 'okhttp-tls'
|| project.name == 'okhttp-urlconnection') {
return project.name
} else {
return null // Not published.
}
}
allprojects {
group = 'com.squareup.okhttp3'
project.ext.artifactId = rootProject.ext.publishedArtifactId(project)
version = '4.10.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url 'https://dl.bintray.com/kotlin/dokka'
}
google()
}
task downloadDependencies() {
description 'Download all dependencies to the Gradle cache'
doLast {
configurations.findAll { it.canBeResolved }.files
}
}
}
ext.applyOsgi = { project ->
project.apply plugin: 'biz.aQute.bnd.builder'
project.sourceSets {
osgi
}
project.jar { t ->
t.setClasspath(project.sourceSets.osgi['compileClasspath'] + project.sourceSets.main['compileClasspath'])
}
project.dependencies {
// The OSGi kotlin-stdlib lets bnd infer bundle versions.
osgiApi deps.kotlinStdlibOsgi
}
}
/** Configure building for Java+Kotlin projects. */
subprojects { project ->
if (project.name == 'android-test') return
if (project.name == 'okhttp-bom') return
if (project.name == 'regression-test') return
apply plugin: "org.jetbrains.kotlin.jvm"
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'checkstyle'
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'biz.aQute.bnd.builder'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
checkstyleMain.exclude '**/CipherSuite.java'
configurations {
checkstyleConfig
}
dependencies {
checkstyleConfig dependencies.create("com.puppycrawl.tools:checkstyle:${versions.checkstyle}") {
transitive = false
}
}
afterEvaluate {
checkstyle {
config = resources.text.fromArchiveEntry(configurations.checkstyleConfig, 'google_checks.xml')
toolVersion "${versions.checkstyle}"
sourceSets = [project.sourceSets.main]
}
}
// Animal Sniffer confirms we generally don't use APIs not on Java 8.
animalsniffer {
annotation "okhttp3.internal.SuppressSignatureCheck"
sourceSets = [sourceSets.main]
}
dependencies {
signature 'net.sf.androidscents.signature:android-api-level-21:5.0.1_r2@signature'
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
}
def platform = System.getProperty("okhttp.platform", "jdk9")
def testJavaVersion = Integer.getInteger("test.java.version", 11)
dependencies {
testRuntimeOnly(deps.junit5JupiterEngine)
testRuntimeOnly(deps.junit5VintageEngine)
}
test {
useJUnitPlatform()
jvmArgs += "-Dokhttp.platform=$platform"
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(testJavaVersion)
}
maxParallelForks Runtime.runtime.availableProcessors() * 2
testLogging {
exceptionFormat = '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.
def alpnBootVersion = alpnBootVersion()
if (alpnBootVersion != null) {
dependencies {
testCompile "org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion"
}
def alpnBootJar = configurations.testCompile.find { it.name.startsWith("alpn-boot-") }
test {
jvmArgs += "-Xbootclasspath/p:${alpnBootJar}"
}
}
} else if (platform == "conscrypt") {
dependencies {
testRuntime "org.conscrypt:conscrypt-openjdk-uber:${versions.conscrypt}"
}
} else if (platform == "openjsse") {
dependencies {
testRuntime deps.openjsse
}
}
tasks.withType(JavaCompile).configureEach {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
dokka {
configuration {
reportUndocumented = false
skipDeprecated = true
jdkVersion = 8
perPackageOption {
prefix = "okhttp3.internal"
suppress = true
}
if (project.file('Module.md').exists()) {
includes = ['Module.md']
}
externalDocumentationLink {
url = new URL("https://square.github.io/okio/2.x/okio/")
packageListUrl = new URL("https://square.github.io/okio/2.x/okio/package-list")
}
}
}
}
/** Configure publishing and signing for published Java and JavaPlatform subprojects. */
subprojects { project ->
if (project.ext.artifactId == null) return
def bom = project.ext.artifactId == 'okhttp-bom'
if (bom) {
apply plugin: 'java-platform'
}
apply plugin: 'maven-publish'
apply plugin: 'signing'
publishing {
if (!bom) {
java {
withJavadocJar()
withSourcesJar()
}
}
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = project.ext.artifactId
version = project.version
if (bom) {
from components.javaPlatform
} else {
from components.java
}
pom {
name = project.name
description = 'Square’s meticulous HTTP client for Java and Kotlin.'
url = 'https://square.github.io/okhttp/'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name = 'Square, Inc.'
}
}
scm {
connection = 'scm:git:https://github.com/square/okhttp.git'
developerConnection = 'scm:git:ssh://[email protected]/square/okhttp.git'
url = 'https://github.com/square/okhttp'
}
}
}
}
repositories {
maven {
name = "mavencentral"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username System.getenv('SONATYPE_NEXUS_USERNAME')
password System.getenv('SONATYPE_NEXUS_PASSWORD')
}
}
}
}
signing {
sign publishing.publications.maven
}
}
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}
/**
* Returns the alpn-boot version specific to this OpenJDK 8 JVM, or null if this is not a Java 8 VM.
* https://github.com/xjdr/xio/blob/master/alpn-boot.gradle
*/
def alpnBootVersion() {
def version = System.getProperty('alpn.boot.version')
if (version != null) {
return version
}
def javaVersion = System.getProperty("java.version")
def patchVersionMatcher = (javaVersion =~ /1\.8\.0_(\d+)(-.*)?/)
if (!patchVersionMatcher.find()) return null
def patchVersion = Integer.parseInt(patchVersionMatcher.group(1))
return alpnBootVersionForPatchVersion(javaVersion, patchVersion)
}
def alpnBootVersionForPatchVersion(String javaVersion, int patchVersion) {
// https://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions
switch (patchVersion) {
case 0..24:
return '8.1.0.v20141016'
case 25..30:
return '8.1.2.v20141202'
case 31..50:
return '8.1.3.v20150130'
case 51..59:
return '8.1.4.v20150727'
case 60..64:
return '8.1.5.v20150921'
case 65..70:
return '8.1.6.v20151105'
case 71..77:
return '8.1.7.v20160121'
case 78..101:
return '8.1.8.v20160420'
case 102..111:
return '8.1.9.v20160720'
case 112..120:
return '8.1.10.v20161026'
case 121..160:
return '8.1.11.v20170118'
case 161..181:
return '8.1.12.v20180117'
case 191..242:
return '8.1.13.v20181017'
default:
throw new IllegalStateException("Unexpected Java version: ${javaVersion}")
}
}
/**
* Returns a .jar file for the golden version of this project.
* https://github.com/Visistema/Groovy1/blob/ba5eb9b2f19ca0cc8927359ce414c4e1974b7016/gradle/binarycompatibility.gradle#L48
*/
ext.baselineJar = { project, version ->
def group = project.group
def artifactId = project.ext.artifactId
try {
String jarFile = "$artifactId-${version}.jar"
project.group = 'virtual_group_for_japicmp' // Prevent it from resolving the current version.
def dependency = project.dependencies.create("$group:$artifactId:$version@jar")
return project.configurations.detachedConfiguration(dependency).files
.find { (it.name == jarFile) }
} finally {
project.group = group
}
}
ext.baselineVersion = "3.14.1"