-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.gradle
executable file
·438 lines (311 loc) · 10.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
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
428
429
430
431
432
433
434
435
436
437
438
import com.github.spotbugs.snom.SpotBugsTask
import io.zucchini.build.docker.DockerPlugin
import io.zucchini.build.node.NodePlugin
import io.zucchini.build.node.YarnTask
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id 'com.github.ben-manes.versions' version '0.51.0'
id 'com.google.osdetector' version '1.7.3'
id 'org.ajoberstar.grgit' version '5.3.0'
id 'com.github.spotbugs' version '5.2.5' apply false
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
}
/**
* Replace version used by a group of dependencies.
*
* @param details Dependency details
* @param group Group of the dependency
* @param version Version to set
*/
void replaceDependencyGroupVersion(DependencyResolveDetails details, String group, String version) {
if (details.requested.group == group || details.requested.group.startsWith(group + '.')) {
details.useVersion version
}
}
allprojects {
group = 'io.zucchini-ui'
apply plugin: 'idea'
apply plugin: DockerPlugin
apply plugin: NodePlugin
repositories {
mavenLocal()
mavenCentral()
}
ext.getDockerTags = {
List<String> dockerTags = []
// Branch slug, without special characters
String branchName = project.grgit.branch.current().name
String branchSlug = branchName.replace('/', '-')
// If the Git branch is the master branch, then the Docker image will be tagged "latest"
dockerTags << "branch-${branchSlug}"
if (branchName == 'master') {
dockerTags << 'latest'
}
return dockerTags
}
// Plugins to use with the java plugin
afterEvaluate {
if (project.pluginManager.hasPlugin('java')) {
// Add common dependencies
project.dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.4'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.4'
testImplementation 'org.assertj:assertj-core:3.27.0'
testImplementation 'org.mockito:mockito-core:5.14.2'
testImplementation 'org.mockito:mockito-junit-jupiter:5.14.2'
}
// Tests
project.test {
useJUnitPlatform()
}
// Maven plugin
project.apply plugin: 'maven-publish'
// PMD plugin
project.apply plugin: 'pmd'
project.pmd {
ignoreFailures = true
}
tasks.withType(Pmd) {
reports {
xml.required = false
html.required = true
}
}
// Spotbugs plugin
project.apply plugin: 'com.github.spotbugs'
project.spotbugs {
ignoreFailures = true
effort = 'max'
}
tasks.withType(SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true
}
}
}
// Shared Java compiler config
project.tasks.withType(JavaCompile) {
options.release = 21
options.encoding = 'UTF-8'
options.deprecation = true
options.compilerArgs << '-parameters'
options.compilerArgs << '-Werror'
}
}
configurations.all {
resolutionStrategy {
// Replace commons logging by slf4j, if present
dependencySubstitution {
substitute module('commons-logging:commons-logging') using module('org.slf4j:jcl-over-slf4j:2.0.16')
}
// Override some dependency versions
eachDependency { DependencyResolveDetails details ->
replaceDependencyGroupVersion(details, 'org.slf4j', '2.0.7')
}
}
}
// Remove milestones, release candidates, etc from dependency updates check
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
selection.candidate.version ==~ /(?i).*-${qualifier}.*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
// Docker compose config
dockerCompose {
environment 'ZUCCHINI_VERSION': "${project.version}"
}
dockerComposeUp {
detach = true
}
}
project("${rootProject.name}-backend") {
apply plugin: 'java'
dependencies {
annotationProcessor 'org.hibernate:hibernate-validator-annotation-processor:8.0.2.Final'
implementation 'io.dropwizard:dropwizard-core:4.0.11'
implementation 'xyz.morphia.morphia:core:1.4.0'
implementation 'xyz.morphia.morphia:logging-slf4j:1.4.0'
implementation 'org.mongodb:mongo-java-driver:3.12.14'
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'org.springframework:spring-context:6.2.1'
implementation 'org.eclipse.jetty.websocket:websocket-jakarta-server:11.0.24'
implementation 'org.apache.commons:commons-text:1.13.0'
}
task runBackend(type: JavaExec, description: 'Run backend server') {
classpath = sourceSets.main.runtimeClasspath
mainClass = 'io.zucchiniui.backend.BackendApplication'
args += ['serve', "${rootDir}/server-config.yml"]
}
}
project("${rootProject.name}-frontend") {
apply plugin: 'java'
project.sourceSets.main.resources.srcDir("$project.buildDir/ui-resources")
task webpack(type: YarnTask, description: 'Run Webpack') {
command = 'run'
args = ['build']
inputs.dir('src')
inputs.file('package.json')
inputs.file('yarn.lock')
inputs.file('postcss.config.js')
inputs.file('webpack.config.js')
inputs.file('babel.config.js')
inputs.file('.browserslistrc')
outputs.dir('build/dist')
}
task jsTest(type: YarnTask, description: 'Test JavaScript') {
command = 'test'
inputs.dir('src')
inputs.file('package.json')
}
tasks.test.dependsOn jsTest
task lint(type: YarnTask, description: 'Lint') {
command = 'lint'
inputs.dir('src')
inputs.file('.eslintrc')
inputs.file(rootProject.file('.eslintrc'))
inputs.file('package.json')
}
tasks.check.dependsOn lint
task copyAssets(type: Copy, dependsOn: webpack) {
from 'build/dist'
into "$project.buildDir/ui-resources/ui"
}
task copyIndexHtml(type: Copy) {
from 'public/index.html'
into "$project.buildDir/ui-resources/ui"
}
task copyPublicContent(type: Copy) {
from('public') {
exclude 'index.html'
}
into "$project.buildDir/ui-resources/public"
}
tasks.processResources.dependsOn(copyAssets, copyIndexHtml, copyPublicContent)
}
project("${rootProject.name}-app") {
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = 'io.zucchiniui.app.ZucchiniUIApplication'
dependencies {
implementation project(":${rootProject.name}-backend")
implementation project(":${rootProject.name}-frontend")
implementation 'io.dropwizard:dropwizard-assets:4.0.11'
}
runShadow {
args 'server', "${rootDir}/server-config.yml"
}
tasks.assemble.dependsOn shadowJar
docker {
name = rootProject.name
tags += project.getDockerTags()
buildArg 'ZUCCHINI_VERSION': "${project.version}"
platforms = ['linux/amd64', 'linux/arm64']
}
task copyLibraries(type: Sync) {
into "$project.buildDir/docker"
from(configurations.runtimeClasspath) {
into "libs"
exclude "${rootProject.name}-*.jar"
}
from(configurations.runtimeClasspath) {
into "app"
include "${rootProject.name}-*.jar"
}
from(jar) {
into "app"
}
}
tasks.dockerBuild.dependsOn tasks.copyLibraries
tasks.dockerPush.dependsOn tasks.copyLibraries
}
project("${rootProject.name}-example-features") {
apply plugin: 'java'
dependencies {
implementation 'info.cukes:cucumber-java:1.2.6'
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'org.assertj:assertj-core:3.27.0'
implementation 'com.google.guava:guava:33.4.0-jre'
}
task runCucumber(type: JavaExec, description: 'Run Cucumber features') {
classpath = sourceSets.main.runtimeClasspath
mainClass = 'cucumber.api.cli.Main'
jvmArgs(
// Required for xtream init
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
'--add-opens',
'java.base/java.lang.reflect=ALL-UNNAMED',
'--add-opens',
'java.base/java.text=ALL-UNNAMED',
'--add-opens',
'java.desktop/java.awt.font=ALL-UNNAMED'
)
args(
'--glue', 'classpath:io.zucchini.examples.glues',
'--plugin', 'pretty',
'--plugin', "html:${project.buildDir}/cucumber/html",
'--plugin', "json:${project.buildDir}/cucumber/report.json",
'--tags', '~@ignored',
'src/features',
)
ignoreExitValue true
}
task dryRunCucumber(type: JavaExec, description: 'Dry run Cucumber features') {
classpath = sourceSets.main.runtimeClasspath
mainClass = 'cucumber.api.cli.Main'
jvmArgs(
// Required for xtream init
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
'--add-opens',
'java.base/java.lang.reflect=ALL-UNNAMED',
'--add-opens',
'java.base/java.text=ALL-UNNAMED',
'--add-opens',
'java.desktop/java.awt.font=ALL-UNNAMED'
)
args(
'--glue', 'classpath:io.zucchini.examples.glues',
'--plugin', 'pretty',
'--plugin', "html:${project.buildDir}/cucumber-dry/html",
'--plugin', "json:${project.buildDir}/cucumber-dry/report.json",
'--dry-run',
'src/features',
)
ignoreExitValue true
}
}
project("${rootProject.name}-mongo") {
docker {
tags += project.getDockerTags()
platforms = ['linux/amd64', 'linux/arm64']
}
}
project("${rootProject.name}-e2e-tests") {
task jsTest(type: YarnTask, description: 'Test E2E') {
command = 'test'
}
task lint(type: YarnTask, description: 'Lint') {
command = 'lint'
inputs.dir('cypress')
inputs.file('.eslintrc')
inputs.file(rootProject.file('.eslintrc'))
inputs.file('package.json')
}
task check
tasks.check.dependsOn lint
}