-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathbuild.gradle
More file actions
218 lines (193 loc) · 7 KB
/
build.gradle
File metadata and controls
218 lines (193 loc) · 7 KB
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
/*
* Copyright (c) 2018-2026 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 java.text.SimpleDateFormat
import org.gradle.api.attributes.java.TargetJvmVersion
plugins {
id "idea"
alias(libs.plugins.artifactory) apply false // applied conditionally from releaser.gradle
alias(libs.plugins.bnd) apply false
alias(libs.plugins.japicmp)
alias(libs.plugins.download)
alias(libs.plugins.jcstress) apply false
alias(libs.plugins.nullability) apply false
alias(libs.plugins.spotless)
}
// The Artifactory plugin (applied from releaser.gradle) adds maven-publish to subprojects
// in afterEvaluate, which resets TargetJvmVersion on consumable configurations to the
// toolchain JDK (21). This pre-registers a callback to force JVM 8 on those configurations,
// keeping them consistent with options.release = 8.
subprojects {
plugins.withType(JavaPlugin) {
configurations.matching { it.name == 'apiElements' || it.name == 'runtimeElements' }.configureEach { conf ->
conf.attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
}
}
}
}
apply from: 'gradle/releaser.gradle'
description = 'Reactive Object Pool root build'
def osgiVersion(String v) {
def m = (v =~ /^(\d+)\.(\d+)\.(\d+)(?:[.-](.+))?$/)
if (!m.matches()) {
throw new GradleException("Cannot parse version: $v")
}
def major = m.group(1)
def minor = m.group(2)
def micro = m.group(3)
def qualifier = m.group(4)
def result
if (qualifier == null || qualifier.isEmpty()) {
result = "${v}.RELEASE"
println "$v is a release, will use $result for bnd"
}
else if (qualifier.equalsIgnoreCase("SNAPSHOT")) {
def sdf = new SimpleDateFormat("yyyyMMddHHmm");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
def buildTimestamp = sdf.format(new Date())
result = "${major}.${minor}.${micro}.BUILD-$buildTimestamp"
println "$v is a snapshot, will use $result for bnd"
}
else {
result = "${major}.${minor}.${micro}.${qualifier}"
println "$v is neither release nor snapshot, will use $result for bnd"
}
return result
}
ext {
isCiServer = System.getenv().containsKey("CI") //doesn't detect Bamboo
jdk = JavaVersion.current().majorVersion
jdkJavadoc = "https://docs.oracle.com/en/java/javase/$jdk/docs/api/"
println "JDK Javadoc link for this build is ${rootProject.jdkJavadoc}"
}
spotless {
if (project.hasProperty("spotlessFrom")) {
if (project.spotlessFrom == "ALL") {
println "[Spotless] Ratchet deactivated"
}
else {
println "[Spotless] Ratchet from $project.spotlessFrom"
ratchetFrom project.spotlessFrom
}
}
else if (isCiServer) {
println "[Spotless] CI detected without explicit branch, not enforcing check"
enforceCheck = false
}
else {
String spotlessBranch = "origin/main"
println "[Spotless] Local run detected, ratchet from $spotlessBranch"
ratchetFrom spotlessBranch
}
java {
target '**/*.java'
licenseHeaderFile('codequality/spotless/licenseSlashstarStyle.txt')
}
}
configure(subprojects) { project ->
group = 'io.projectreactor.addons'
apply plugin: 'java-library'
apply plugin: 'jacoco'
apply plugin: 'biz.aQute.bnd.builder'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
apply plugin: 'io.spring.nullability'
apply from: "${rootDir}/gradle/doc.gradle"
apply from: "${rootDir}/gradle/setup.gradle"
jacocoTestReport {
reports {
xml.required = true
html.required = true
}
}
[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"
]
tasks.withType(JavaCompile).configureEach { task ->
if (task.name.matches("compile(\\d+)?Java")) {
options.errorprone {
option("NullAway:AssertsEnabled", "true")
}
}
}
compileJava {
options.release = 8
}
compileTestJava {
options.release = 8
options.compilerArgs += "-parameters"
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.test.resources.srcDirs = ["src/test/resources", "src/test/java"]
project.tasks.withType(Test).all {
scanForTestClasses = false
include '**/*Tests.*'
include '**/*Test.*'
exclude '**/*Abstract*.*'
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
}
}
test {
//configure tag support for the core test task
def tags = rootProject.findProperty("junit-tags")
if (tags != null) {
println "junit5 tags: $tags"
useJUnitPlatform() {
includeTags "$tags"
}
}
else {
useJUnitPlatform()
}
testLogging {
events "passed", "failed"
showExceptions = true
exceptionFormat = "full"
showStandardStreams = true
}
}
repositories {
mavenCentral()
maven { url = "https://oss.sonatype.org/content/repositories/releases/" }
if (version.endsWith('-SNAPSHOT') || version.contains('-SNAPSHOT-')) { //classic or customized snapshots
maven { url = 'https://repo.spring.io/snapshot' }
}
}
}
configurations.all {
// check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}