forked from pgentile/zucchini-ui
-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle
executable file
·385 lines (267 loc) · 9.68 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
import com.github.spotbugs.SpotBugsTask
import io.zucchini.build.docker.DockerPlugin
import io.zucchini.build.node.NodePlugin
import io.zucchini.build.node.YarnTask
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
jcenter()
}
}
plugins {
id 'com.github.ben-manes.versions' version '0.27.0'
id 'com.google.osdetector' version '1.6.2'
id 'org.ajoberstar.grgit' version '4.0.1'
id 'com.github.spotbugs' version '3.0.0' apply false
id 'com.github.johnrengelman.shadow' version '5.2.0' 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
apply plugin: 'com.github.ben-manes.versions'
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 'junit:junit:4.13'
testImplementation 'org.assertj:assertj-core:3.15.0'
testImplementation 'org.mockito:mockito-core:3.2.4'
}
// Maven plugin
project.apply plugin: 'maven-publish'
// PMD plugin
project.apply plugin: 'pmd'
project.pmd {
ignoreFailures = true
}
tasks.withType(Pmd) {
reports {
xml.enabled = false
html.enabled = true
}
}
// Spotbugs plugin
// Only on JDK < 11
if (JavaVersion.current() <= JavaVersion.VERSION_11) {
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) {
project.sourceCompatibility = '11'
project.targetCompatibility = '11'
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') with module('org.slf4j:jcl-over-slf4j:1.7.26')
}
// Override some dependency versions
eachDependency { DependencyResolveDetails details ->
replaceDependencyGroupVersion(details, 'org.slf4j', '1.7.26')
}
}
}
// 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')
}
}
}
}
}
project("${rootProject.name}-backend") {
apply plugin: 'java'
dependencies {
annotationProcessor 'org.hibernate:hibernate-validator-annotation-processor:6.1.2.Final'
implementation 'io.dropwizard:dropwizard-core:2.0.1'
implementation 'ma.glasnost.orika:orika-core:1.5.4'
implementation 'xyz.morphia.morphia:core:1.4.0'
implementation 'xyz.morphia.morphia:logging-slf4j:1.4.0'
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'org.springframework:spring-context:5.2.3.RELEASE'
implementation 'org.eclipse.jetty.websocket:javax-websocket-server-impl:9.4.18.v20190429'
implementation 'org.apache.commons:commons-text:1.8'
implementation 'com.rabbitmq:amqp-client:5.9.0'
implementation 'org.javassist:javassist:3.26.0-GA'
implementation 'javax.xml.bind:jaxb-api:2.3.1'
runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
testImplementation 'org.assertj:assertj-core:3.12.2'
testImplementation 'com.pholser:junit-quickcheck-core:0.9.1'
testImplementation 'com.pholser:junit-quickcheck-generators:0.9.1'
}
task runBackend(type: JavaExec, description: 'Run backend server') {
classpath = sourceSets.main.runtimeClasspath
main = 'io.zucchiniui.backend.BackendApplication'
args += ['serve', "${rootDir}/server-config.yml"]
}
task runJsonImporter(type: JavaExec, description: 'Execute JsonImportTest') {
classpath = sourceSets.main.runtimeClasspath
main = 'io.zucchiniui.backend.JsonImportTest'
if (project.hasProperty('jsonFilePath')) {
args = [jsonFilePath]
}
}
}
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('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.dir('test')
inputs.file('package.json')
}
task copyAssets(type: Copy, dependsOn: webpack) {
from 'build/dist'
into "$project.buildDir/ui-resources/ui"
}
task copyIndexHtml(type: Copy) {
from 'index.html'
into "$project.buildDir/ui-resources/ui"
}
tasks.processResources.dependsOn(copyAssets, copyIndexHtml)
tasks.test.dependsOn jsTest
}
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:2.0.1'
}
runShadow {
args 'server', "${rootDir}/server-config.yml"
}
shadowJar {
mergeServiceFiles()
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
}
tasks.assemble.dependsOn shadowJar
docker {
name = rootProject.name
tags += project.getDockerTags()
}
dockerBuild {
buildArg 'ZUCCHINI_VERSION': "${project.version}"
}
dockerComposeUp {
detach = true
environment 'ZUCCHINI_VERSION': "${project.version}"
}
}
project("${rootProject.name}-example-features") {
apply plugin: 'java'
dependencies {
implementation 'info.cukes:cucumber-java:1.2.6'
implementation 'org.slf4j:slf4j-api:1.7.26'
implementation 'org.assertj:assertj-core:3.12.2'
implementation 'com.google.guava:guava:28.2-jre'
}
task runCucumber(type: JavaExec, description: 'Run Cucumber features') {
classpath = sourceSets.main.runtimeClasspath
main = 'cucumber.api.cli.Main'
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
main = 'cucumber.api.cli.Main'
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()
}
}
project("${rootProject.name}-e2e-tests") {
task jsTest(type: YarnTask, description: 'Test E2E') {
command = 'test'
}
}