forked from square/okhttp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
256 lines (232 loc) · 7.87 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
import net.ltgt.gradle.errorprone.CheckSeverity
buildscript {
ext.versions = [
'airline': '2.6.0',
'android': '4.1.1.4',
'animalSniffer': '1.17',
'assertj': '3.11.0',
'bouncycastle': '1.60',
'checkstyle': '8.15',
'conscrypt': '2.1.0',
'findbugs': '3.0.2',
'guava': '27.0.1-jre',
'java': '1.8',
'jnrUnixsocket': '0.22',
'jsoup': '1.11.3',
'junit': '4.12',
'kotlin': '1.3.40',
'moshi': '1.8.0',
'okio': '2.2.2',
'ktlint': '0.31.0'
]
ext.deps = [
'airline': "com.github.rvesse:airline:${versions.airline}",
'android': "com.google.android:android:${versions.android}",
'animalSniffer': "org.codehaus.mojo:animal-sniffer-annotations:${versions.animalSniffer}",
'assertj': "org.assertj:assertj-core:${versions.assertj}",
'bouncycastle': "org.bouncycastle:bcprov-jdk15on:${versions.bouncycastle}",
'conscrypt': "org.conscrypt:conscrypt-openjdk-uber:${versions.conscrypt}",
'guava': "com.google.guava:guava:${versions.guava}",
'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}",
'kotlinStdlib': "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}",
'moshi': "com.squareup.moshi:moshi:${versions.moshi}",
'okio': "com.squareup.okio:okio:${versions.okio}"
]
dependencies {
// TODO(jwilson): configure maven-publish-plugin to limit which artifacts are published.
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.7.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.18"
classpath 'com.diffplug.spotless:spotless-plugin-gradle:3.21.1'
}
repositories {
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id 'ru.vyarus.animalsniffer' version '1.5.0'
id 'com.github.johnrengelman.shadow' version '4.0.1'
id 'me.champeau.gradle.japicmp' version '0.2.6'
}
allprojects {
group = GROUP
version = VERSION_NAME
repositories {
mavenCentral()
maven {
url 'https://dl.bintray.com/kotlin/dokka'
}
}
task downloadDependencies() {
description 'Download all dependencies to the Gradle cache'
doLast {
configurations.findAll { it.canBeResolved }.files
}
}
}
subprojects { project ->
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'org.jetbrains.kotlin.platform.jvm'
apply plugin: 'checkstyle'
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'com.diffplug.gradle.spotless'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
checkstyleMain.exclude '**/CipherSuite.java'
afterEvaluate {
checkstyle {
configFile = rootProject.file('checkstyle.xml')
toolVersion "${versions.checkstyle}"
sourceSets = [project.sourceSets.main]
}
}
// Animal Sniffer confirms we don't use APIs not on both Java 8 and Android 5.
animalsniffer {
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'
}
spotless {
kotlin {
target "**/*.kt"
ktlint(versions.ktlint).userData(['indent_size': '2', 'continuation_indent_size': '2'])
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
}
def platform = System.getProperty("okhttp.platform", "jdk8")
test {
jvmArgs += "-Dlistener=okhttp3.testing.InstallUncaughtExceptionHandlerListener"
jvmArgs += "-Dokhttp.platform=$platform"
testLogging {
exceptionFormat = 'full'
}
}
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}"
}
}
dependencies {
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
errorprone 'com.google.errorprone:error_prone_core:2.3.3'
}
tasks.withType(JavaCompile).configureEach {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
options.errorprone {
check("MissingFail", CheckSeverity.ERROR)
check("MissingOverride", CheckSeverity.ERROR)
enabled = JavaVersion.current() < JavaVersion.VERSION_12
}
}
// We have to set the dokka configuration after evaluation since the com.vanniktech.maven.publish
// plugin overwrites our dokka configuration on projects where it's applied.
afterEvaluate { p ->
p.tasks.dokka {
reportUndocumented = false
skipDeprecated = true
jdkVersion = 8
packageOptions {
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/jvm/index.html")
packageListUrl = new URL("https://square.github.io/okio/2.x/okio/jvm/package-list")
}
}
}
}
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 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) {
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..212:
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.property("GROUP")
def artifactId = project.property("POM_ARTIFACT_ID")
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"