forked from reactor/reactor-netty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
391 lines (319 loc) · 11.4 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
/*
* Copyright (c) 2011-2019 Pivotal Software Inc, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.api.internal.plugins.osgi.OsgiHelper
buildscript {
repositories {
maven { url "https://repo.spring.io/plugins-release" }
}
dependencies {
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7',
'io.spring.gradle:spring-io-plugin:0.0.4.RELEASE',
'com.google.gradle:osdetector-gradle-plugin:1.4.0'
}
}
plugins {
id "com.github.hierynomus.license" version "0.14.0"
id 'org.asciidoctor.convert' version '1.5.11'
id 'com.github.johnrengelman.shadow' version '5.0.0'
}
description = 'Reactive Streams Netty driver'
ext {
if (project.hasProperty('versionBranch') && version.toString().endsWith(".BUILD-SNAPSHOT")) {
versionBranch = versionBranch.replaceAll("\"", "").trim()
if (!versionBranch.isEmpty()) {
realVersion = version.toString().replace("BUILD-SNAPSHOT", versionBranch + ".BUILD-SNAPSHOT")
project.version = realVersion
println "Building special snapshot ${project.version}"
println "OSGI version would be: ${new OsgiHelper().getVersion(project.version.toString())}"
}
}
gradleScriptDir = "${rootProject.projectDir}/gradle"
reactorCoreVersion = "3.3.1.BUILD-SNAPSHOT"
reactorPoolVersion = "0.1.0.RELEASE"
blockHoundVersion = "1.0.0.RC1"
//Metrics
micrometerVersion = 'latest.release'
// Logging
slf4jVersion = '1.7.12'
logbackVersion = '1.1.2'
testAddonVersion = reactorCoreVersion
assertJVersion = '3.6.1'
// Libraries
nettyVersion = '4.1.39.Final'
jacksonDatabindVersion = '2.5.1'
// Testing
mockitoVersion = '1.10.19'
hoverflyJavaVersion = '0.11.1'
javadocLinks = ["https://docs.oracle.com/javase/7/docs/api/",
"https://docs.oracle.com/javaee/6/api/",
"https://fasterxml.github.io/jackson-databind/javadoc/2.5/",
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
"https://projectreactor.io/docs/core/release/api/",
"https://netty.io/4.1/api/",
"https://projectreactor.io/docs/netty/release/api/",] as String[]
}
configure(rootProject) { project ->
group = 'io.projectreactor.netty'
apply plugin: 'java'
apply plugin: 'jacoco'
apply from: "$gradleScriptDir/setup.gradle"
apply plugin: 'propdeps'
apply plugin: 'osgi'
apply from: "${gradleScriptDir}/ide.gradle"
apply from: "${gradleScriptDir}/errorprone.gradle"
apply plugin: 'com.google.osdetector'
jacoco {
toolVersion = '0.7.7.201606060606'
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
ext.bundleImportPackages = [ '!javax.annotation',
'io.netty.channel.kqueue;resolution:=optional;version="[4.1,5)"',
'!reactor.pool',
'io.micrometer.*;resolution:=optional',
'*']
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:varargs",
"-Xlint:cast",
"-Xlint:classfile",
"-Xlint:dep-ann",
"-Xlint:divzero",
"-Xlint:empty",
"-Xlint:finally",
"-Xlint:overrides",
"-Xlint:path",
"-Xlint:processing",
"-Xlint:static",
"-Xlint:try",
"-Xlint:deprecation",
"-Xlint:unchecked",
"-Xlint:-serial", // intentionally disabled
"-Xlint:-options", // intentionally disabled
"-Xlint:-fallthrough", // intentionally disabled
"-Xlint:rawtypes"
]
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
if (JavaVersion.current().isJava8Compatible()) {
compileTestJava.options.compilerArgs += "-parameters"
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.test.resources.srcDirs = ["src/test/resources", "src/test/java"]
configurations.all {
exclude group: 'commons-logging', module: 'commons-logging'
}
project.tasks.withType(Test).all {
// run tests with IPv4 only when IPv6 is available
if (project.hasProperty('preferIPv4Stack')) {
systemProperty("java.net.preferIPv4Stack", "true")
}
// run tests with preferring IPv6 addresses
if (project.hasProperty('preferIPv6Addresses')) {
systemProperty("java.net.preferIPv6Addresses", "true")
}
systemProperty("java.awt.headless", "true")
systemProperty("reactor.trace.cancel", "true")
systemProperty("reactor.trace.nocapacity", "true")
systemProperty("testGroups", project.properties.get("testGroups"))
systemProperty("io.netty.leakDetection.level", "paranoid")
scanForTestClasses = false
include '**/*Tests.*'
include '**/*Test.*'
include '**/*Spec.*'
exclude '**/*Abstract*.*'
}
test {
testLogging {
events "passed", "failed"
showExceptions true
exceptionFormat "full"
maxGranularity 3
}
onOutput { descriptor, event ->
if (event.message.contains("ResourceLeakDetector")) {
logger.error("ERROR: Test: " + descriptor + " produced resource leak: " + event.message )
}
}
}
sourceSets {
jarFileTest
}
idea.module.testSourceDirs += sourceSets.jarFileTest.allSource.srcDirs
repositories {
mavenCentral()
if (version.endsWith('BUILD-SNAPSHOT') || project.hasProperty('platformVersion')) {
if (System.getenv ()["bamboo_buildNumber"] == null) {
mavenLocal()
} else {
println 'Bamboo CI detected, avoiding use of mavenLocal()'
}
maven { url 'https://repo.spring.io/libs-snapshot' }
}
maven { url 'https://repo.spring.io/libs-milestone' }
maven { url 'https://repo.spring.io/libs-release' }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
jcenter()
}
def os_suffix = ""
if (osdetector.classifier in ["linux-x86_64"] || ["osx-x86_64"] || ["windows-x86_64"]) {
os_suffix = ":" + osdetector.classifier
}
configurations {
shaded
}
// dependencies that are common across all java projects
dependencies {
// JSR-305 annotations
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
compile "io.netty:netty-handler-proxy:${nettyVersion}"
compile "io.netty:netty-codec-http2:${nettyVersion}"
optional "io.netty:netty-codec-haproxy:${nettyVersion}"
//Metrics
optional "io.micrometer:micrometer-core:${micrometerVersion}"
// Logging
optional "org.slf4j:slf4j-api:$slf4jVersion"
compile "io.projectreactor:reactor-core:$reactorCoreVersion"
shaded("io.projectreactor.addons:reactor-pool:$reactorPoolVersion") {
exclude module: "reactor-core"
}
optional "io.projectreactor.tools:blockhound:$blockHoundVersion"
compile "io.netty:netty-handler:${nettyVersion}"
compile "io.netty:netty-codec-http:${nettyVersion}"
compile "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
optional "io.netty:netty-transport-native-kqueue:${nettyVersion}"
// Testing
testCompile "com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion"
testCompile "io.projectreactor:reactor-test:$testAddonVersion"
testCompile "org.hamcrest:hamcrest-library:1.3"
testCompile "org.assertj:assertj-core:$assertJVersion"
testCompile "io.specto:hoverfly-java:${hoverflyJavaVersion}"
testCompile "org.apache.tomcat.embed:tomcat-embed-core:9.0.20"
testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion"
testRuntime "ch.qos.logback:logback-classic:$logbackVersion"
// Needed for HTTP/2 testing
testRuntime "io.netty:netty-tcnative-boringssl-static:2.0.25.Final" + os_suffix
jarFileTestCompile 'org.assertj:assertj-core:3.12.2'
jarFileTestCompile 'junit:junit:4.12'
for (dependency in project.configurations.shaded.dependencies) {
compileOnly(dependency)
}
}
if (project.hasProperty('platformVersion')) {
apply plugin: 'spring-io'
repositories {
maven { url 'https://repo.spring.io/libs-snapshot' }
}
dependencyManagement {
springIoTestRuntime {
imports {
mavenBom "io.spring.platform:platform-bom:$platformVersion"
}
}
}
}
jar {
classifier = 'original'
manifest {
instruction 'Import-Package', bundleImportPackages.join(',')
attributes("Created-By": "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})",
"Implementation-Title": project.name,
"Implementation-Version": project.version,
"Automatic-Module-Name": "reactor.netty")
}
}
check.dependsOn jacocoTestReport
shadowJar {
classifier = null
dependsOn(project.tasks.jar)
manifest {
inheritFrom project.tasks.jar.manifest
}
configurations = [project.configurations.shaded]
project.afterEvaluate {
dependencies {
def shadedDependencies = project.configurations
.shaded
.dependencies
.collect { "${it.group}:${it.name}".toString() }
.toSet()
// Exclude every compile-scoped dependency (including the transitive ones)
for (id in project.configurations.compile.resolvedConfiguration.resolvedArtifacts*.moduleVersion*.id) {
def module = "${id.group}:${id.name}".toString()
if (!shadedDependencies.contains(module)) {
project.configurations.shaded.exclude(group: id.group, module: id.name)
exclude(dependency(module))
}
}
}
}
exclude 'META-INF/maven*/**'
}
task relocateShadowJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "reactor.netty.internal.shaded"
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar
artifacts.archives shadowJar
task jarFileTest(type: Test) {
testClassesDirs = sourceSets.jarFileTest.output.classesDirs
classpath = sourceSets.jarFileTest.runtimeClasspath
systemProperty("jarFile", shadowJar.outputs.files.singleFile)
dependsOn(shadowJar)
}
project.tasks.check.dependsOn(jarFileTest)
project.tasks.compileTestJava.classpath += configurations.shaded
project.tasks.test.classpath += configurations.shaded
task shadedJarTest(type: Test) {
testClassesDirs = sourceSets.test.output.classesDirs
Set<? super File> mainOutputs = [
project.sourceSets.main.output.resourcesDir,
project.sourceSets.main.java.outputDir,
]
classpath = shadowJar.outputs.files
// Exclude main outputs since we have the shaded JAR on the classpath already
classpath += sourceSets.test.runtimeClasspath.filter { !(it in mainOutputs) }
//The imports are not relocated, we do relocation only for the main sources not the tests
exclude '**/*PooledConnectionProviderTest*.*'
dependsOn(shadowJar)
}
project.tasks.check.dependsOn(shadedJarTest)
}
configurations.all {
// check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
license {
header rootProject.file('codequality/HEADER')
includes(["**/*.java", "**/*.css"])
strictCheck true
mapping {
java = 'SLASHSTAR_STYLE'
css = 'SLASHSTAR_STYLE'
}
}
}