This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
427 lines (372 loc) · 15.6 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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/*
* MIT License
*
* Copyright (c) 2022-2023 TweetWallFX
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
plugins {
id 'base'
id 'build-dashboard'
id 'java-platform'
id 'com.diffplug.spotless' version '6.22.0'
id 'com.github.ben-manes.versions' version '0.49.0'
id 'com.github.spotbugs' version '5.2.1' apply false
id 'com.google.osdetector' version '1.7.3'
id 'com.netflix.nebula.info' version '12.1.6' apply false
id 'com.netflix.nebula.maven-base-publish' version '20.3.0' apply false
id 'net.ltgt.errorprone' version '3.1.0' apply false
id 'org.sonarqube' version '4.4.1.3373'
id 'com.autonomousapps.dependency-analysis' version '1.25.0'
}
ext {
javaFxPlatform = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os
javaFxPlatform = osdetector.arch == 'aarch_64' ? javaFxPlatform + '-aarch64' : javaFxPlatform
}
javaPlatform {
allowDependencies()
}
dependencies {
api platform('org.junit:junit-bom:5.10.0')
api platform('org.apache.logging.log4j:log4j-bom:2.21.1')
constraints {
api 'com.github.spotbugs:spotbugs-annotations:4.8.0'
api 'jakarta.ws.rs:jakarta.ws.rs-api:3.1.0'
api 'org.slf4j:slf4j-api:2.0.9'
}
}
allprojects {
int[] versionSplit = currentVersion.split('[.]').collect{it as int}
assert 3 == versionSplit.length : 'currentVersion property requires all three version parts (major, minor, patch)'
group = mavenGroupName
version = String.format('release' == System.getenv('GITHUB_REF_NAME') ? '%d.%d.%d' : '%d.%d-SNAPSHOT', versionSplit)
description = "${projectDescriptionBase} (${name})"
repositories {
mavenCentral()
jcenter()
}
// configuring Spotless
apply plugin: 'com.diffplug.spotless'
afterEvaluate {
spotless {
if (!System.env.CI) {
// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
// only format files which have changed since this ref
// TODO: Figure out a way to get this working in CI (i.e. Github Workflows)
ratchetFrom 'origin/main'
}
format 'textBasedFiles', {
target(
'*.gradle',
'**/*.gradle',
'**/*.asciidoc',
'**/*.adoc',
'**/*.asc',
'**/*.css',
'**/*.json',
'**/*.md',
'**/*.properties',
'.gitignore',
)
targetExclude(
'.*/**',
)
trimTrailingWhitespace()
indentWithSpaces(4)
endWithNewline()
replaceRegex 'noMultipleEmptyLines', '\n{3,}', '\n\n'
}
def closure = {
trimTrailingWhitespace()
indentWithSpaces(4)
endWithNewline()
importOrder(
'\\#', // static imports
'com', // classes from com root package
'java', // classes from java root package
'javafx', // classes from javafx root package
'javax', // classes from javax root package
'jakarta', // classes from javax root package
'org', // classes from org root package
'', // any other import
)
replaceRegex 'noStarImports', /\nimport (static )?[a-zA-Z0-9.]*[.][\*];\n/, '\n'
replaceRegex 'noMultipleEmptyLines', '\n{3,}', '\n\n'
replaceRegex 'Remove @author javadoc taglets.', '\n\\s*\\*\\s*@author.*', ''
replaceRegex 'Remove trailing empty comment lines.', '\n\\s*\\*(\n\\s*\\*/\n)', '$1'
replaceRegex 'Remove empty javadoc', '\n\\s*/\\*\\*\n\\s*\\*/\n', '\n\n'
replaceRegex 'Remove empty lines before end of block', '\\n[\\n]+(\\s*})(?=\\n)', '\n$1'
licenseHeaderFile rootProject.file('LICENSE.spotlessJavaTemplate')
}
if (plugins.hasPlugin(GroovyPlugin)) {
groovy(closure)
} else if (plugins.hasPlugin(JavaPlugin)) {
java(closure)
}
}
tasks.named('check') {
dependsOn spotlessCheck
}
}
// configuring dependencyAnalysis
plugins.withType(com.autonomousapps.DependencyAnalysisPlugin) {
if (rootProject == project) {
dependencyAnalysis {
issues {
all { // applies to all projects
onUsedTransitiveDependencies {
severity 'ignore'
}
onUnusedDependencies {
severity 'warn' // default
}
onRedundantPlugins {
severity 'fail'
}
}
}
}
afterEvaluate {
tasks.named('buildHealth').configure {
printBuildHealth = true
}
}
}
}
// now configuring for projects that contain code not just structuring the project
if (childProjects.isEmpty()) {
// configuring standard java project
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'eclipse'
apply plugin: 'com.netflix.nebula.info'
apply plugin: 'maven-publish'
java {
withJavadocJar()
withSourcesJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(Integer.parseInt(System.getenv('JAVA_PLATFORM_VERSION') ?: '17')))
}
}
jacoco {
toolVersion = '0.8.10'
}
configurations {
javafx {
description = 'Java FX libraries'
}
jaxb {
description = 'JAXB libraries'
}
all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.ow2.asm' &&
details.requested.name == 'asm') {
details.useVersion '9.5'
details.because 'workaround for spotbugs not yet supporting JDK 21 class formats'
}
/*
if (details.requested.group == 'com.fasterxml.jackson' &&
details.requested.name == 'jackson-bom' &&
details.requested.version == '2.13.2.1') {
details.useVersion '2.13.2.20220324'
details.because 'fixes CVE-2020-36518 and resolved version does not (pom) match expectation'
}
*/
}
}
compileOnly {
extendsFrom configurations.javafx
}
testFramework {
description = 'Libraries for testing'
// exclude old junit api
exclude group: 'junit'
}
testImplementation.extendsFrom testFramework
}
dependencies {
// get recommended versions from the platform project
api platform(rootProject)
javafx group: 'org.openjfx', name: 'javafx-base', version: '21.0.1', classifier: javaFxPlatform
javafx group: 'org.openjfx', name: 'javafx-graphics', version: '21.0.1', classifier: javaFxPlatform
javafx group: 'org.openjfx', name: 'javafx-fxml', version: '21.0.1', classifier: javaFxPlatform
javafx group: 'org.openjfx', name: 'javafx-controls', version: '21.0.1', classifier: javaFxPlatform
jaxb 'jakarta.activation:jakarta.activation-api:2.1.2'
jaxb 'org.eclipse.angus:angus-activation:2.0.1'
jaxb 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.1'
jaxb 'org.glassfish.jaxb:jaxb-runtime:4.0.4'
testFramework 'org.assertj:assertj-core:3.24.2'
testFramework 'org.junit.jupiter:junit-jupiter-api'
testFramework 'org.junit.jupiter:junit-jupiter-params'
testFramework 'org.mockito:mockito-junit-jupiter:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.platform:junit-platform-runner'
testRuntimeOnly 'org.mockito:mockito-inline:5.2.0'
}
ext {
getJvmModulePath = { -> (configurations.javafx + configurations.jaxb).asPath}
getJvmAdditionalModules = { ->
[
'jakarta.activation',
'jakarta.xml.bind',
'javafx.controls',
'javafx.fxml',
'javafx.graphics',
].toUnique().toSorted().join(',')
}
}
tasks.named('jar') {
manifest.attributes provider: 'gradle'
}
tasks.named('javadoc') {
options.addStringOption('-module-path', getJvmModulePath())
options.addStringOption('-add-modules', getJvmAdditionalModules())
enabled = false // TODO: re-enable (currently breaks build with ClassCastException)
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs.addAll([
// lint everithing except preview (as using preview features would generate a warnig and thus break the build)
'-Xlint:all,-preview',
'--enable-preview',
'-Werror',
'-proc:none',
'--module-path',
getJvmModulePath(),
'--add-modules',
getJvmAdditionalModules(),
])
}
tasks.withType(JavaExec).configureEach {
jvmArgs '--enable-preview'
jvmArgs '--module-path'
jvmArgs getJvmModulePath()
jvmArgs '--add-modules'
jvmArgs getJvmAdditionalModules()
jvmArgs '--add-opens'
jvmArgs 'java.base/jdk.internal.misc=ALL-UNNAMED'
}
tasks.withType(Test).configureEach {
jvmArgs '--enable-preview'
jvmArgs '--module-path'
jvmArgs getJvmModulePath()
jvmArgs '--add-modules'
jvmArgs getJvmAdditionalModules()
systemProperty 'org.tweetwallfx.tests.executeConferenceClientLiveTests', executeConferenceClientLiveTests
useJUnitPlatform()
testLogging {
events 'skipped', 'passed', 'failed'
}
}
tasks.named('check') {
dependsOn javadoc
}
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_18)) {
// jacoco not yet compatible with JDK18
tasks.named('test') {
finalizedBy jacocoTestReport
}
}
// configuring Errorprone
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorprone 'com.google.errorprone:error_prone_core:2.23.0'
}
if (System.env.CI || project.findProperty('applySpotbugs')) {
// configuring Spotbugs
apply plugin: 'com.github.spotbugs'
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {
// fail build in case a failure was detected
ignoreFailures = false
jvmArgs.add '--module-path'
jvmArgs.add getJvmModulePath()
jvmArgs.add '--add-modules'
jvmArgs.add getJvmAdditionalModules()
excludeFilter = rootProject.file('spotbugs-exclude.xml')
reports {
xml.required.set(false)
html.required.set(true)
}
auxClassPaths = auxClassPaths + configurations.javafx + configurations.jaxb
}
}
// configuring Versions plugin
tasks.withType(com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask).configureEach {
outputFormatter = 'plain,html'
gradleReleaseChannel = 'current'
resolutionStrategy {
def rejectedQualifierParts = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview', 'b', 'pr', 'ea']
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = rejectedQualifierParts.any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-+]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
}
plugins.withType(GroovyPlugin) {
dependencies {
implementation 'org.codehaus.groovy:groovy-all:4.0.2'
testFramework 'org.spockframework:spock-core:2.3-groovy-4.0'
}
}
apply plugin: 'com.netflix.nebula.maven-base-publish'
apply plugin: 'com.netflix.nebula.publish-verification'
}
}
if (extensions.findByName('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
tasks.register('createFolders') {
description = 'Creates the folders for the projects and sourceSets should they not exist.'
rootProject.allprojects.each {p ->
if (!p.getProjectDir().isDirectory()) {
logger.lifecycle 'Creating project folder: {}', p.getProjectDir()
p.getProjectDir().mkdirs()
}
if (p.hasProperty('sourceSets')) {
p.sourceSets*.allSource*.srcDirs*.each { File srcDir ->
if (!srcDir.isDirectory()) {
logger.lifecycle 'Creating source folder: {}', srcDir
srcDir.mkdirs()
}
}
}
}
}
subprojects { project ->
if (!project.projectDir.name.contains('-') &&
new File(project.projectDir, 'src/main/resources').listFiles().collect().find{it.name.endsWith('.css')}) {
plugins.withType(JavaPlugin) {
rootProject.tasks.register('run' + project.projectDir.name.capitalize()) {
group = 'Runner'
description = 'Runs the ' + project.projectDir.name.capitalize() + ' Tweetwall'
dependsOn project.path + ':run'
}
}
}
}