/
build.gradle
285 lines (241 loc) · 9.9 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
/*
* Copyright (c) 2020-2022 VMware, Inc. or its affiliates, 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 aQute.bnd.gradle.BundleTaskConvention
import me.champeau.gradle.japicmp.JapicmpTask
apply plugin: 'java-test-fixtures'
apply plugin: 'io.spring.javadoc'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'me.champeau.gradle.japicmp'
apply plugin: 'de.undercouch.download'
apply plugin: 'biz.aQute.bnd.builder'
ext {
bndOptions = [
"Export-Package" : "reactor.netty*;version=$osgiVersion;-noimport:=true",
"Import-Package": [
"!javax.annotation",
"io.netty.channel.kqueue;resolution:=optional;version=\"[4.1,5)\"",
"io.netty.incubator.channel.uring;resolution:=optional",
"io.micrometer.*;resolution:=optional",
"*"
].join(","),
"Bundle-Name" : "reactor-netty-core",
"Bundle-SymbolicName" : "io.projectreactor.netty.reactor-netty-core",
"Bundle-Version" : "$osgiVersion"
]
}
sourceSets {
jarFileTest
}
configurations {
shaded
}
dependencies {
// JSR-305 annotations
compileOnly "com.google.code.findbugs:jsr305:$jsr305Version"
api "io.netty:netty-handler:$nettyVersion"
api "io.netty:netty-handler-proxy:$nettyVersion"
api "io.netty:netty-resolver-dns:$nettyVersion"
if (!"$nettyVersion".endsWithAny("SNAPSHOT")) {
if (osdetector.classifier == "osx-x86_64" || osdetector.classifier == "osx-aarch_64") {
api "io.netty:netty-resolver-dns-native-macos:$nettyVersion$os_suffix"
}
else {
api "io.netty:netty-resolver-dns-native-macos:$nettyVersion:osx-x86_64"
}
}
else {
// MacOS binaries are not available for Netty SNAPSHOT version
api "io.netty:netty-resolver-dns-native-macos:$nettyVersion"
}
//transport resolution: typical build forces epoll but not kqueue transitively
//on the other hand, if we want to make transport-specific tests, we'll make all
// native optional at compile time and add correct native/nio to testRuntime
if (project.hasProperty("forceTransport")) {
//so that the main code compiles
compileOnly "io.netty:netty-transport-native-epoll:$nettyVersion"
compileOnly "io.netty:netty-transport-native-kqueue:$nettyVersion"
compileOnly "io.netty.incubator:netty-incubator-transport-native-io_uring:$nettyIoUringVersion"
testImplementation "io.netty:netty-transport-native-epoll:$nettyVersion"
testImplementation "io.netty:netty-transport-native-kqueue:$nettyVersion"
testImplementation "io.netty.incubator:netty-incubator-transport-native-io_uring:$nettyIoUringVersion"
//now we explicitly add correctly qualified native, or do nothing if we want to test NIO
if (forceTransport == "native") {
if (osdetector.os == "osx") {
testImplementation "io.netty:netty-transport-native-kqueue:$nettyVersion$os_suffix"
}
else if (osdetector.os == "linux") {
testImplementation "io.netty:netty-transport-native-epoll:$nettyVersion$os_suffix"
}
}
else if (forceTransport == "io_uring" && osdetector.os == "linux") {
testImplementation "io.netty.incubator:netty-incubator-transport-native-io_uring:$nettyIoUringVersion$os_suffix"
}
else if (forceTransport != "nio") {
throw new InvalidUserDataException("invalid -PforceTranport option " + forceTransport + ", should be native|nio")
}
}
else {
//classic build to be distributed
api "io.netty:netty-transport-native-epoll:$nettyVersion:linux-x86_64"
compileOnly "io.netty:netty-transport-native-kqueue:$nettyVersion"
compileOnly "io.netty.incubator:netty-incubator-transport-native-io_uring:$nettyIoUringVersion"
testImplementation "io.netty:netty-transport-native-kqueue:$nettyVersion"
testImplementation "io.netty.incubator:netty-incubator-transport-native-io_uring:$nettyIoUringVersion"
}
//Metrics
compileOnly "io.micrometer:micrometer-core:$micrometerVersion"
// Logging
compileOnly "org.slf4j:slf4j-api:$slf4jVersion"
api "io.projectreactor:reactor-core:$reactorCoreVersion"
shaded("io.projectreactor.addons:reactor-pool:$reactorPoolVersion") {
exclude module: "reactor-core"
}
// Testing
// JSR-305 annotations
testCompileOnly "com.google.code.findbugs:jsr305:$jsr305Version"
testImplementation "com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion"
testImplementation "io.projectreactor:reactor-test:$testAddonVersion"
testImplementation "io.projectreactor.addons:reactor-extra:$reactorAddonsVersion"
testImplementation "org.assertj:assertj-core:$assertJVersion"
testImplementation "org.awaitility:awaitility:$awaitilityVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
testImplementation "io.projectreactor.tools:blockhound-junit-platform:$blockHoundVersion"
testImplementation "io.micrometer:micrometer-core:$micrometerVersion"
testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junitPlatformLauncherVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
testRuntimeOnly "org.slf4j:jcl-over-slf4j:$slf4jVersion"
for (dependency in project.configurations.shaded.dependencies) {
compileOnly(dependency)
testImplementation(dependency)
}
jarFileTestImplementation "org.assertj:assertj-core:$assertJVersion"
jarFileTestImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
jarFileTestRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}
jar {
archiveClassifier.set('original')
manifest {
attributes("Automatic-Module-Name": "reactor.netty.core")
}
bnd(bndOptions)
}
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
task downloadBaseline(type: Download) {
onlyIf {
if (project.gradle.startParameter.isOffline()) {
println "Offline: skipping downloading of baseline and JAPICMP"
return false
}
else if ("$compatibleVersion" == "SKIP") {
println "SKIP: Instructed to skip the baseline comparison"
return false
}
else {
println "Will download and perform baseline comparison with ${compatibleVersion}"
return true
}
}
onlyIfNewer true
compress true
src "${repositories.mavenCentral().url}io/projectreactor/netty/reactor-netty-core/$compatibleVersion/reactor-netty-core-${compatibleVersion}-original.jar"
dest "${buildDir}/baselineLibs/reactor-netty-core-${compatibleVersion}-original.jar"
}
task japicmp(type: JapicmpTask) {
oldClasspath.from(files("${buildDir}/baselineLibs/reactor-netty-core-${compatibleVersion}-original.jar"))
newClasspath.from(files(jar.archiveFile))
onlyBinaryIncompatibleModified = true
failOnModification = true
failOnSourceIncompatibility = true
txtOutputFile = file("${project.buildDir}/reports/japi.txt")
ignoreMissingClasses = true
includeSynthetic = true
onlyIf { "$compatibleVersion" != "SKIP" }
methodExcludes = [
"reactor.netty.resources.ConnectionProvider#create(java.lang.String, int, boolean)"
]
}
tasks.japicmp.dependsOn(downloadBaseline)
tasks.check.dependsOn(japicmp)
shadowJar {
configure {
it.convention.plugins.bundle = new BundleTaskConvention(it)
doLast {
buildBundle()
}
}
bnd(bndOptions)
archiveClassifier.set(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.compileClasspath.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(relocateShadowJar)
//delay the maven publishing so that the OSGi metadata is generated
//then add shadowJar to the publication
components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
skip()
}
publishing.publications.mavenJava.artifact(shadowJar)
task jarFileTest(type: Test) {
testClassesDirs = sourceSets.jarFileTest.output.classesDirs
classpath = sourceSets.jarFileTest.runtimeClasspath
systemProperty("jarFile", shadowJar.outputs.files.singleFile)
dependsOn(shadowJar)
}
tasks.check.dependsOn(jarFileTest)
task shadedJarTest(type: Test) {
testClassesDirs = sourceSets.test.output.classesDirs
Set<? super File> mainOutputs = [
project.sourceSets.main.output.resourcesDir,
project.sourceSets.main.java.classesDirectory,
]
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)
}
tasks.check.dependsOn(shadedJarTest)
description = "Core functionality for the Reactor Netty library"