-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle
405 lines (348 loc) · 17.3 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
plugins {
// core plugins
id 'java'
id 'application'
id 'eclipse'
id 'maven-publish' // mandatory plugin, to publish on Nexus with dependencies. the plugin needs the configuration block "publishing" (see publishing.gradle)
id 'jacoco'
id 'pmd'
id 'checkstyle'
// community plugins
id 'com.diffplug.spotless' version '6.25.0'
id 'net.ltgt.errorprone' version '4.0.1'
id 'com.github.spotbugs' version '6.0.19'
id 'org.ajoberstar.grgit' version '5.2.2'
id 'com.github.ksoichiro.console.reporter' version '0.6.3'
id 'se.bjurr.violations.violations-gradle-plugin' version '2.1.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'org.sonarqube' version '5.1.0.4882'
id 'team.yi.semantic-gitlog' version '0.6.12'
}
group = 'io.neonbee'
version = '0.37.3-SNAPSHOT'
mainClassName = 'io.neonbee.Launcher'
archivesBaseName = 'neonbee-core'
sourceCompatibility = 17
project.ext {
isReleaseVersion = !version.endsWith('-SNAPSHOT')
distributionDir = file("${buildDir}/dist")
distributionLibsDir = file("${distributionDir}/libs")
generatedTrustStorePassword = UUID.randomUUID().toString()
}
repositories {
mavenCentral()
}
dependencies {
// Framework dependencies
def vertx_version = '4.5.9'
implementation group: 'io.vertx', name: 'vertx-core', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-web', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-web-client', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-web-openapi-router', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-config', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-config-yaml', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-micrometer-metrics', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-auth-common', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-auth-htpasswd', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-auth-htdigest', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-auth-jwt', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-auth-oauth2', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-hazelcast', version: vertx_version
implementation group: 'io.vertx', name: 'vertx-health-check', version: vertx_version
def hazelcast_version = '5.3.8'
implementation group: 'com.hazelcast', name: 'hazelcast', version: hazelcast_version
implementation (group: 'io.vertx', name: 'vertx-infinispan', version: vertx_version) {
exclude group: 'org.infinispan', module: 'infinispan-core'
exclude group: 'org.infinispan', module: 'infinispan-commons'
exclude group: 'org.infinispan', module: 'infinispan-multimap'
}
def infinispan_version = '14.0.29.Final'
implementation group: 'org.infinispan', name: 'infinispan-multimap-jakarta', version: infinispan_version
implementation group: 'org.infinispan', name: 'infinispan-core-jakarta', version: infinispan_version
implementation group: 'org.infinispan', name: 'infinispan-clustered-lock', version: infinispan_version
implementation group: 'org.infinispan', name: 'infinispan-clustered-counter', version: infinispan_version
implementation group: 'org.infinispan', name: 'infinispan-component-annotations', version: infinispan_version
def jackson_version = '2.17.2'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: jackson_version
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jackson_version
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jackson_version
def olingo_version = '5.0.0'
implementation(group: 'org.apache.olingo', name: 'odata-server-core', version: olingo_version) {
exclude group: 'io.netty'
}
implementation group: 'org.apache.olingo', name: 'odata-server-core-ext', version: olingo_version
implementation group: 'com.sap.cds', name: 'cds4j-core', version: '3.0.0'
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.12.6'
implementation group: 'org.ow2.asm', name: 'asm', version: '9.7'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.13'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.5.6'
def guava_version = '33.2.1-jre'
implementation group: 'com.google.guava', name: 'guava', version: guava_version
implementation group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: '4.8.6'
// Compile only
compileOnly group: 'io.vertx', name: 'vertx-codegen', version: vertx_version
// Annotation processors
annotationProcessor group: 'io.vertx', name: 'vertx-codegen', classifier: 'processor', version: vertx_version
// Framework test dependencies
testImplementation group: 'io.vertx', name: 'vertx-core', classifier: 'tests', version: vertx_version
testImplementation group: 'io.vertx', name: 'vertx-junit5', version: vertx_version
def truth_version = '1.4.4'
testImplementation group: 'com.google.truth', name: 'truth', version: truth_version
testImplementation group: 'com.google.guava', name: 'guava-testlib', version: guava_version
def mockito_version = '5.2.0'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: mockito_version
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: mockito_version
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.14.18'
def jupiter_version = '5.10.3'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jupiter_version
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jupiter_version
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: jupiter_version
testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.3'
// Required for Eclipse to run Unit tests.
def junit_platform_version = '1.10.3'
testImplementation group: 'org.junit.platform', name: 'junit-platform-commons', version: junit_platform_version
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: junit_platform_version
// Gradle plugin dependencies
errorprone group: 'com.google.errorprone', name: 'error_prone_core', version: '2.29.2'
checkstyle group: 'com.puppycrawl.tools', name: 'checkstyle', version: '10.17.0'
// Without this the IDE can't find the test source files which are needed for debugging
testCompileOnly group: 'io.vertx', name: 'vertx-core', classifier: 'test-sources', version: vertx_version
}
// fix checkstyle wrongfully using google collections instead of Guava
configurations.checkstyle {
resolutionStrategy.capabilitiesResolution.withCapability('com.google.collections:google-collections') {
select('com.google.guava:guava:0')
}
}
// we need to define the generated source set first, because it is needed by staticCodeCheck
sourceSets {
generated {
java {
srcDir 'src/generated/java'
}
}
}
apply from: 'gradle/distribution.gradle'
apply from: 'gradle/publishing.gradle'
apply from: 'gradle/codeCoverage.gradle'
apply from: 'gradle/release.gradle'
apply from: 'gradle/staticCodeCheck.gradle'
apply from: 'gradle/changelog.gradle'
// ############ Annotation Processing
task annotationProcessing(type: JavaCompile, group: 'build') {
options.annotationProcessorPath = configurations.annotationProcessor
inputs.dir 'src/main/java'
outputs.dir 'src/generated/java'
source = sourceSets.main.java
classpath = configurations.compileClasspath
destinationDirectory = project.file('src/generated/java')
options.compilerArgs = [
"-proc:only",
"-processor", "io.vertx.codegen.CodeGenProcessor"
]
}
// please note that due to this import the whole annotation processing cannot be split off to an own script
// plugin (apply from: ...) due to we must use the JavaExtension on the classpath loaded by the above plugin block.
// re-importing it in the script plugin, even with a own buildscript block, will not work, trust me! ;)
import com.diffplug.gradle.spotless.JavaExtension
import com.diffplug.spotless.LineEnding
def spotlessGeneratedExtension = new JavaExtension(spotless)
spotlessGeneratedExtension.target sourceSets.generated.java.srcDirs
spotlessGeneratedExtension.encoding 'UTF8'
spotlessGeneratedExtension.trimTrailingWhitespace()
spotlessGeneratedExtension.removeUnusedImports()
spotlessGeneratedExtension.endWithNewline()
spotlessGeneratedExtension.setLineEndings(LineEnding.UNIX)
spotlessGeneratedExtension.importOrderFile("${rootDir}/gradle/spotless/neonbee.importorder")
spotlessGeneratedExtension.eclipse('4.17').configFile "${rootDir}/gradle/spotless/eclipse-formatter.xml"
spotlessGeneratedExtension.custom 'Lambda fix', { it.replace('} )', '})').replace('} ,', '},') }
def spotlessApplyGenerated = spotlessGeneratedExtension.createIndependentApplyTask('spotlessApplyGenerated')
spotlessApplyGenerated.mustRunAfter('annotationProcessing')
spotlessApplyGeneratedHelper.mustRunAfter('annotationProcessing')
task generateCode {
dependsOn annotationProcessing
dependsOn spotlessApplyGenerated
}
compileJava {
dependsOn generateCode
source += sourceSets.generated.java
options.compilerArgs += '-proc:none'
}
compileGeneratedJava {
// This task will be automatically executed when calling "gradlew build", but the generated sources were already
// build in the customized "compileJava" task. Therefore there is no need to compile the classes again.
// This compilation would also produce compiling issues, because this classpath doesn't contain all dependencies.
source = []
}
clean {
delete += sourceSets.generated.java.srcDirs
}
//// ############ Test Phase
tasks.withType(Test).configureEach {
// Required list of packages that are accessed by the ReflectionHelper
// (Note: this list can be treated as "technical debt" because in tests we want to prevent setting / getting private fields as best as possible)
jvmArgs += [
// internal Java packages
'java.lang',
'java.lang.reflect',
'java.util',
// NeonBee (test) packages
'io.neonbee',
'io.neonbee.data',
'io.neonbee.entity',
'io.neonbee.internal.helper',
'io.neonbee.internal.json',
'io.neonbee.internal.scanner',
'io.neonbee.endpoint.odatav4.internal.olingo.expression',
'io.neonbee.test.helper',
// Vert.x packages
'io.vertx.test.fakecluster',
'io.vertx.micrometer.backends',
'io.vertx.core.json',
'io.vertx.core.json.jackson'
].collect {
['--add-opens', "java.base/${it}=ALL-UNNAMED"]
}.flatten()
// run tests sequentially on the voter, as it is often slow and leads to failing tests
if (!org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX() ||
System.getenv('CI') == null) {
systemProperties = [
'junit.jupiter.execution.parallel.enabled' : 'true',
'junit.jupiter.execution.parallel.mode.default' : 'concurrent',
'junit.jupiter.execution.parallel.mode.classes.default': 'concurrent'
]
}
systemProperty 'junit.jupiter.execution.timeout.mode', 'enabled'
environment 'vertx.parameter.filename', file('src/test/resources/vertx-parameters.json').absolutePath
// Later, if the violations plugin supports JUNIT5 we have to ignore the issues
// during SpotBugs run, because the violations plugin will display the issues
// and let the build fail later. But currently we have to fail directly.
ignoreFailures = false
dependsOn('spotlessCheck', 'cleanTest')
testLogging {
events 'passed', 'skipped', 'failed'
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
// Full display of exceptions
// Don't show complete standard out and standard error of the tests on the console.
// Show only verbose output for failing tests.
showStandardStreams = false
}
reports {
junitXml {
required = true
outputLocation = file("${buildDir}/reports/junit/xml")
}
html {
required = true
outputLocation = file("${buildDir}/reports/junit/html")
}
}
}
task unitTest(type: Test, group: 'verification') {
useJUnitPlatform { excludeTags 'longRunningTest' }
def unitTestTimeout = project.hasProperty('unitTestTimeout') ? project.getProperty('unitTestTimeout') : '5s'
systemProperty 'junit.jupiter.execution.timeout.lifecycle.method.default', unitTestTimeout
systemProperty 'junit.jupiter.execution.timeout.testable.method.default', unitTestTimeout
}
task longRunningTest(type: Test, group: 'verification') {
useJUnitPlatform { includeTags 'longRunningTest' }
def longRunningTestTimeout = project.hasProperty('longRunningTestTimeout') ? project.getProperty('longRunningTestTimeout') : '30s'
systemProperty 'junit.jupiter.execution.timeout.test.method.default', longRunningTestTimeout
systemProperty 'junit.jupiter.execution.timeout.lifecycle.method.default', longRunningTestTimeout
mustRunAfter 'unitTest'
}
test {
def testPlan = project.hasProperty('testPlan') ? project.getProperty('testPlan') : 'default'
if(testPlan == 'withGlobalTimeout') {
dependsOn ('unitTest', 'longRunningTest')
} else if (testPlan == 'default') {
// when running tests with the default plan, the default timeout of 30s will be used
useJUnitPlatform {}
} else {
throw new GradleException('Test plan ' + testPlan + ' does not exist')
}
finalizedBy jacocoTestReport
}
// ############ SonarQube Plugin
sonarqube {
properties {
property 'sonar.sourceEncoding', 'UTF-8'
property "sonar.projectKey", "neonbee_key"
property "sonar.organization", "neonbee"
property "sonar.host.url", "https://sonarcloud.io"
property 'sonar.coverage.jacoco.xmlReportPaths', "${buildDir}/reports/jacoco/xml/jacoco.xml"
property 'sonar.junit.reportPaths', "${buildDir}/reports/junit/xml"
property 'sonar.gradle.skipCompile', 'true'
}
}
// ############ Violations Plugin
task violations(type: se.bjurr.violations.gradle.plugin.ViolationsTask) {
maxReporterColumnWidth = 10 // 0 means "no limit"
maxRuleColumnWidth = 50
maxSeverityColumnWidth = 10
maxLineColumnWidth = 10
maxMessageColumnWidth = 200
minSeverity = 'INFO' // INFO, WARN or ERROR
detailLevel = 'VERBOSE' // PER_FILE_COMPACT, COMPACT or VERBOSE
maxViolations = 0 // Fail the build if total number of found violations is higher
printViolations = true
// Formats are listed here: https://github.com/tomasbjerre/violations-lib
violations = [
['FINDBUGS', buildDir.path, ".*/build/reports/spotbugs/.*\\.xml\$",'Spotbugs'],
['JUNIT', buildDir.path, ".*/build/reports/junit/xml/.*\\.xml\$",'JUnit'],
['PMD', buildDir.path, ".*/build/reports/pmd/.*\\.xml\$", 'PMD'],
['CHECKSTYLE', buildDir.path, ".*/build/reports/checkstyle/.*\\.xml\$", 'Checkstyle']
]
}
check.finalizedBy violations
test.finalizedBy violations
unitTest.finalizedBy violations
longRunningTest.finalizedBy violations
build.finalizedBy violations
// ############ JavaDoc Build
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
import org.gradle.internal.logging.events.OutputEvent
import org.gradle.internal.logging.events.OutputEventListener
import org.gradle.internal.logging.LoggingOutputInternal
tasks.withType(Javadoc) {
def exceptions = []
doFirst {
gradle.services.get(LoggingOutputInternal).addOutputEventListener(new OutputEventListener() {
void onOutput(OutputEvent event) {
String eventString = event.toString()
if (eventString =~ " warning: ") {
if (eventString =~ " warning: no comment") {
// Ignore warnings if a class is missing a JavaDoc,
// therefore we have checkstyle
// With Java 18 we can also suppress this warnings in the console
// https://bugs.openjdk.java.net/browse/JDK-8189591
} else {
exceptions << "Javadoc warning: ${event.toString()}"
}
}
}
})
}
doLast {
if (exceptions.size() > 0) {
throw new GradleException(String.join('\n', exceptions))
}
}
}
// ############ Release
task release(type: Exec) {
workingDir projectDir
if (project.hasProperty('nextVersion')) {
def nextVersion = project.getProperty('nextVersion')
println 'Releasing next version ' + nextVersion
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine 'cmd', '/c', 'gradle/release.sh', nextVersion
} else {
commandLine 'sh', '-c', "./gradle/release.sh ${nextVersion}"
}
}
}