forked from square/okhttp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
258 lines (229 loc) · 6.69 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
buildscript {
dependencies {
classpath Dependencies.kotlinPlugin
classpath Dependencies.dokkaPlugin
classpath Dependencies.androidPlugin
classpath Dependencies.androidJunit5Plugin
classpath Dependencies.graalPlugin
classpath Dependencies.bndPlugin
classpath Dependencies.shadowPlugin
classpath Dependencies.japicmpPlugin
classpath Dependencies.animalsnifferPlugin
classpath Dependencies.errorpronePlugin
classpath Dependencies.spotlessPlugin
}
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
}
allprojects {
group = 'com.squareup.okhttp3'
project.ext.artifactId = Projects.publishedArtifactId(project.name)
version = '5.0.0-SNAPSHOT'
repositories {
mavenCentral()
google()
maven { url 'https://dl.bintray.com/kotlin/dokka' }
}
task downloadDependencies() {
description 'Download all dependencies to the Gradle cache'
doLast {
configurations.findAll { it.canBeResolved }.files
}
}
normalization {
runtimeClasspath {
metaInf {
ignoreAttribute("Bnd-LastModified")
}
}
}
}
/** 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: "com.diffplug.spotless"
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'biz.aQute.bnd.builder'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
vendor = JvmVendorSpec.ADOPTOPENJDK
}
}
checkstyleMain.exclude '**/CipherSuite.java'
configurations {
checkstyleConfig
}
dependencies {
checkstyleConfig dependencies.create(Dependencies.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 Dependencies.signatureAndroid21
signature Dependencies.signatureJava18
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = ['-Xjvm-default=compatibility', '-Xopt-in=kotlin.RequiresOptIn']
}
}
def platform = System.getProperty("okhttp.platform", "jdk9")
def testJavaVersion = Integer.getInteger("test.java.version", 11)
dependencies {
testRuntimeOnly(Dependencies.junit5JupiterEngine)
testRuntimeOnly(Dependencies.junit5VintageEngine)
}
test {
useJUnitPlatform()
jvmArgs += "-Dokhttp.platform=$platform"
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(testJavaVersion)
vendor = JvmVendorSpec.ADOPTOPENJDK
}
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 = Alpn.alpnBootVersion()
if (alpnBootVersion != null) {
def alpnBootJar = configurations.detachedConfiguration(
dependencies.create("org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion")).singleFile
test {
jvmArgs += "-Xbootclasspath/p:${alpnBootJar}"
}
}
} else if (platform == "conscrypt") {
dependencies {
testRuntimeOnly Dependencies.conscrypt
}
} else if (platform == "openjsse") {
dependencies {
testRuntimeOnly Dependencies.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
}
perPackageOption {
prefix = "mockwebserver3.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
}