-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
739 lines (637 loc) · 26.1 KB
/
build.gradle.kts
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
/*
* SPDX-FileCopyrightText: 2024 Lifely
* SPDX-License-Identifier: EUPL-1.2+
*/
import com.diffplug.gradle.spotless.SpotlessExtension
import com.github.gradle.node.npm.task.NpmTask
import io.gitlab.arturbosch.detekt.Detekt
import io.smallrye.openapi.api.OpenApiConfig
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
import java.util.Locale
plugins {
java
war
jacoco
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.jsonschema2pojo)
alias(libs.plugins.openapi.generator)
alias(libs.plugins.gradle.node)
alias(libs.plugins.taskinfo)
alias(libs.plugins.openapi)
alias(libs.plugins.swagger.generator)
alias(libs.plugins.detekt)
alias(libs.plugins.spotless)
alias(libs.plugins.allopen)
alias(libs.plugins.noarg)
}
repositories {
mavenLocal()
mavenCentral()
}
group = "net.atos.common-ground"
description = "Zaakafhandelcomponent"
val branchName by extra {
if (project.hasProperty("branchName")) {
project.property("branchName").toString()
} else {
"localdev"
}
}
val commitHash by extra {
if (project.hasProperty("commitHash")) {
project.property("commitHash").toString()
} else {
"localdev"
}
}
// create custom configuration for the JaCoCo agent JAR used to generate code coverage of our integration tests
// see: https://blog.akquinet.de/2018/09/06/test-coverage-for-containerized-java-apps/
val jacocoAgentJarForItest: Configuration by configurations.creating {
isTransitive = false
}
// sets the Java version for all Koltin and Java compilation tasks (source and target compatibility)
// make sure the Java version is supported by WildFly
// and update our base Docker image and JDK versions in our GitHubs workflows accordingly
val javaVersion = 21
val versionNumber by extra {
if (project.hasProperty("versionNumber")) {
project.property("versionNumber").toString()
} else {
"dev"
}
}
// create custom configuration for extra dependencies that are required in the generated WAR
val warLib: Configuration by configurations.creating {
extendsFrom(configurations["compileOnly"])
}
val zacDockerImage by extra {
if (project.hasProperty("zacDockerImage")) {
project.property("zacDockerImage").toString()
} else {
"ghcr.io/infonl/zaakafhandelcomponent:dev"
}
}
val srcGenerated = layout.projectDirectory.dir("src/generated")
val srcMainResources = layout.projectDirectory.dir("src/main/resources")
val srcMainApp = layout.projectDirectory.dir("src/main/app")
val srcE2e = layout.projectDirectory.dir("src/e2e")
sourceSets {
// create custom integration test source set
create("itest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(libs.kotlinx.coroutines.core)
implementation(libs.apache.commons.lang)
implementation(libs.apache.commons.text)
implementation(libs.apache.commons.collections)
implementation(libs.commons.io)
implementation(libs.opencsv)
implementation(libs.flowable.engine)
implementation(libs.flowable.cdi)
implementation(libs.flowable.cmmn.engine)
implementation(libs.flowable.cmmn.cdi)
implementation(libs.flowable.cmmn.engine.configurator)
implementation(libs.slf4j.jdk14)
implementation(libs.auth0.java.jwt)
implementation(libs.javax.cache.api)
implementation(libs.google.guava)
implementation(libs.itextpdf.kernel)
implementation(libs.itextpdf.layout)
implementation(libs.itextpdf.io)
implementation(libs.itextpdf.html2pdf)
implementation(libs.flyway.core)
implementation(libs.flyway.postgresql)
implementation(libs.apache.solr)
implementation(libs.webdav.servlet)
implementation(libs.htmlcleaner)
implementation(libs.unboundid.ldapsdk)
implementation(libs.caffeine)
implementation(libs.jackson.core)
implementation(libs.jackson.annotations)
implementation(libs.jackson.kotlin)
implementation(libs.jackson.jsr310)
implementation(libs.opentelemetry.api)
implementation(libs.opentelemetry.instrumentation.annotations)
implementation(libs.opentelemetry.extension.kotlin)
swaggerUI(libs.swagger.ui)
// enable detekt formatting rules. see: https://detekt.dev/docs/rules/formatting/
detektPlugins(libs.detekt.formatting)
runtimeOnly(libs.infinispan.jcache)
runtimeOnly(libs.infinispan.cdi.embedded)
// declare dependencies that are required in the generated WAR; see war section below
// simply marking them as 'compileOnly' or 'implementation' does not work
warLib(libs.apache.httpclient)
warLib(libs.reactive.streams)
// WildFly does already include the Jakarta Mail API lib so not sure why, but we need to
// include it in the WAR or else ZAC will fail to be deployed
warLib(libs.jakarta.mail)
// dependencies provided by Wildfly
// update these versions when upgrading WildFly
// you can find most of these dependencies in the WildFly pom.xml file
// of the WidFly version you are using on https://github.com/wildfly/wildfly
// for others you need to check the 'modules' directory of your local WildFly installation
providedCompile(libs.jakarta.jakartaee)
providedCompile(libs.eclipse.microprofile.rest.client.api)
providedCompile(libs.eclipse.microprofile.config.api)
providedCompile(libs.eclipse.microprofile.health.api)
providedCompile(libs.eclipse.microprofile.fault.tolerance.api)
providedCompile(libs.jboss.resteasy.multipart.provider)
providedCompile(libs.wildfly.security.elytron.http.oidc)
providedCompile(libs.hibernate.validator)
// ~dependencies provided by Wildfly
// yasson is required for using a JSONB context in our unit tests
// where we do not have the WildFly runtime environment available
testImplementation(libs.eclipse.yasson)
testImplementation(libs.kotest.runner.junit5)
testImplementation(libs.mockk)
testImplementation(libs.json)
// Hibernate Validator requires an implementation of the Jakarta Expression Language
// runtime this is provided for by the WildFly runtime environment
// for our unit tests we use the reference implementation
testImplementation(libs.glassfish.expressly)
// integration test dependencies
"itestImplementation"(libs.testcontainers.testcontainers)
"itestImplementation"(libs.testcontainers.mockserver)
"itestImplementation"(libs.testcontainers.postgresql)
"itestImplementation"(libs.json)
"itestImplementation"(libs.kotest.runner.junit5)
"itestImplementation"(libs.kotest.assertions.json)
"itestImplementation"(libs.slf4j.simple)
"itestImplementation"(libs.okhttp)
"itestImplementation"(libs.okhttp.urlconnection)
"itestImplementation"(libs.auth0.java.jwt)
"itestImplementation"(libs.github.kotlin.logging)
"itestImplementation"(libs.kotlin.csv.jvm)
jacocoAgentJarForItest(variantOf(libs.jacoco.agent) { classifier("runtime") })
}
allOpen {
// enable all-open plugin for Kotlin so that WildFly's dependency injection framework (Weld)
// can proxy our Kotlin classes when they have our custom annotation
// because by default Kotlin classes are final
annotation("nl.lifely.zac.util.AllOpen")
}
noArg {
// enable no-arg plugin for Kotlin so that WildFly's dependency injection framework (Weld)
// can instantiate our Kotlin classes without a no-arg constructor
annotation("nl.lifely.zac.util.NoArgConstructor")
}
jacoco {
toolVersion = libs.versions.jacoco.get()
}
java {
// add our generated client code to the main source set
sourceSets["main"].java
.srcDir(srcGenerated.dir("productaanvraag/java"))
.srcDir(srcGenerated.dir("kvk/zoeken/java"))
.srcDir(srcGenerated.dir("kvk/basisprofiel/java"))
.srcDir(srcGenerated.dir("kvk/vestigingsprofiel/java"))
.srcDir(srcGenerated.dir("brp/java"))
.srcDir(srcGenerated.dir("bag/java"))
.srcDir(srcGenerated.dir("klanten/java"))
.srcDir(srcGenerated.dir("zgw/brc/java"))
.srcDir(srcGenerated.dir("zgw/drc/java"))
.srcDir(srcGenerated.dir("zgw/zrc/java"))
.srcDir(srcGenerated.dir("zgw/ztc/java"))
.srcDir(srcGenerated.dir("or/objects/java"))
.srcDir(srcGenerated.dir("or/objecttypes/java"))
}
jsonSchema2Pojo {
// generates Java model files for the "productaanvraag" JSON schema(s)
setSource(srcMainResources.dir("json-schemas/productaanvraag").asFileTree)
setSourceType("jsonschema")
targetDirectory = srcGenerated.dir("productaanvraag/java").asFile
targetPackage = "net.atos.zac.productaanvraag.model.generated"
setAnnotationStyle("JSONB2")
dateType = "java.time.LocalDate"
dateTimeType = "java.time.ZonedDateTime"
timeType = "java.time.LocalTime"
includeHashcodeAndEquals = false
includeToString = false
initializeCollections = false
includeAdditionalProperties = false
}
kotlin {
// set the Java version for all Kotlin and Java compilation tasks
// including source and target compatibility
// see: https://www.baeldung.com/kotlin/gradle-kotlin-bytecode-version
jvmToolchain(javaVersion)
}
node {
download.set(true)
version.set(libs.versions.nodejs.get())
distBaseUrl.set("https://nodejs.org/dist")
nodeProjectDir.set(srcMainApp.asFile)
if (System.getenv("CI") != null) {
npmInstallCommand.set("ci")
} else {
npmInstallCommand.set("install")
}
}
smallryeOpenApi {
infoTitle.set("Zaakafhandelcomponent backend API")
schemaFilename.set("META-INF/openapi/openapi")
operationIdStrategy.set(OpenApiConfig.OperationIdStrategy.METHOD)
outputFileTypeFilter.set("YAML")
}
swaggerSources {
register("zaakafhandelcomponent") {
setInputFile(file("$rootDir/build/generated/openapi/META-INF/openapi/openapi.yaml"))
}
}
configure<SpotlessExtension> {
format("misc") {
target(".gitattributes", ".gitignore", ".containerignore", ".dockerignore")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
targetExclude("src/generated/**", "build/generated/**")
removeUnusedImports()
importOrderFile("config/importOrder.txt")
formatAnnotations()
// Latest supported version:
// https://github.com/diffplug/spotless/tree/main/lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_wtp_formatter
eclipse(libs.versions.spotless.eclipse.formatter.get()).configFile("config/zac.xml")
}
format("e2e") {
target("src/e2e/**/*.js", "src/e2e/**/*.ts")
targetExclude("src/e2e/node_modules/**")
prettier(
mapOf(
"prettier" to libs.versions.spotless.prettier.base.get(),
"prettier-plugin-organize-imports" to libs.versions.spotless.prettier.organize.imports.get()
)
).config(mapOf("parser" to "typescript", "plugins" to arrayOf("prettier-plugin-organize-imports")))
}
gherkin {
target("src/e2e/**/*.feature")
targetExclude("src/e2e/node_modules/**")
gherkinUtils()
}
format("app") {
target("src/main/app/**/*.js", "src/main/app/**/*.ts")
targetExclude(
"src/main/app/node_modules/**",
"src/main/app/dist/**",
"src/main/app/.angular/**"
)
targetExclude(
"src/main/app/node_modules/**",
"src/main/app/src/generated/**",
"src/main/app/coverage/**",
"src/main/app/dist/**",
"src/main/app/.angular/**"
)
prettier(
mapOf(
"prettier" to libs.versions.spotless.prettier.base.get(),
"prettier-plugin-organize-imports" to libs.versions.spotless.prettier.organize.imports.get()
)
).config(mapOf("parser" to "typescript", "plugins" to arrayOf("prettier-plugin-organize-imports")))
}
format("json") {
target("src/**/*.json")
targetExclude(
"src/e2e/node_modules/**",
"src/e2e/reports/**",
"src/main/app/node_modules/**",
"src/main/app/dist/**",
"src/main/app/.angular/**",
"src/**/package-lock.json",
"src/main/app/coverage/**.json"
)
prettier(mapOf("prettier" to libs.versions.spotless.prettier.base.get())).config(mapOf("parser" to "json"))
}
format("html") {
target("src/**/*.html", "src/**/*.htm")
targetExclude(
"src/e2e/node_modules/**",
"src/e2e/reports/**",
"src/main/app/node_modules/**",
"src/main/app/dist/**",
"src/main/app/.angular/**",
)
prettier(mapOf("prettier" to libs.versions.spotless.prettier.base.get())).config(mapOf("parser" to "html"))
}
format("less") {
target("src/**/*.less")
targetExclude(
"src/e2e/node_modules/**",
"src/e2e/reports/**",
"src/main/app/node_modules/**",
"src/main/app/dist/**",
"src/main/app/.angular/**",
)
prettier(mapOf("prettier" to libs.versions.spotless.prettier.base.get())).config(mapOf("parser" to "less"))
}
}
tasks {
clean {
dependsOn("mavenClean")
delete(srcMainApp.dir("dist"))
delete(srcMainApp.dir("reports"))
delete(srcMainApp.dir("src/generated"))
delete(srcMainApp.dir("coverage"))
delete(srcGenerated)
delete(srcE2e.dir("reports"))
}
build {
dependsOn("generateWildflyBootableJar")
}
test {
dependsOn("npmRunTest")
}
compileJava {
dependsOn("generateJavaClients")
}
compileKotlin {
dependsOn("generateJavaClients")
}
jacocoTestReport {
dependsOn(test)
reports {
xml.required = true
html.required = false
}
}
processResources {
// exclude resources that we do not need in the build artefacts
exclude("api-specs/**")
exclude("wildfly/**")
}
register<Detekt>("detektApply") {
description = "Apply detekt fixes."
autoCorrect = true
ignoreFailures = true
}
withType<Detekt>().configureEach {
config.setFrom("$rootDir/config/detekt.yml")
setSource(files("src/main/kotlin", "src/test/kotlin", "src/itest/kotlin", "build.gradle.kts"))
// our Detekt configuration build builds upon the default configuration
buildUponDefaultConfig = true
}
getByName("spotlessApply").finalizedBy(listOf("detektApply"))
getByName("generateSwaggerUIZaakafhandelcomponent").setDependsOn(listOf("generateOpenApiSpec"))
getByName("compileItestKotlin") {
dependsOn("copyJacocoAgentForItest")
mustRunAfter("buildDockerImage")
}
withType<JacocoReport> {
// exclude Java client code that was auto generated at build time
afterEvaluate {
classDirectories.setFrom(
classDirectories.files.map {
fileTree(it).matching {
exclude("**/generated/**")
}
}
)
}
}
withType<Test> {
useJUnitPlatform()
}
withType<Javadoc> {
options.encoding = "UTF-8"
}
withType<JavaCompile> {
options.encoding = "UTF-8"
}
withType<War> {
dependsOn("npmRunBuild")
// add built frontend resources to WAR archive
from("src/main/app/dist/zaakafhandelcomponent")
// explicitly add our 'warLib' 'transitive' dependencies that are required in the generated WAR
classpath(files(configurations["warLib"]))
}
// Generic configuration for the generate Java clients tasks.
// Note that we do not specify one generic output directory but instead
// specify a specific non-overlapping output directory per task so that
// Gradle can cache the outputs for these tasks.
withType<GenerateTask> {
generatorName.set("java")
generateApiTests.set(false)
generateApiDocumentation.set(false)
generateModelTests.set(false)
generateModelDocumentation.set(false)
globalProperties.set(
mapOf(
// generate model files only (note that an empty string indicates: generate all)
"modelDocs" to "false",
"apis" to "false",
"models" to ""
)
)
configOptions.set(
mapOf(
"library" to "microprofile",
"microprofileRestClientVersion" to libs.versions.microprofile.rest.client.get(),
"sourceFolder" to "",
"dateLibrary" to "java8",
"disallowAdditionalPropertiesIfNotPresent" to "false",
"openApiNullable" to "false",
"useJakartaEe" to "true"
)
)
// Specify custom Mustache template dir as temporary workaround for the issue where OpenAPI Generator
// fails to generate import statements for @JsonbCreator annotations.
templateDir.set("$rootDir/src/main/resources/openapi-generator-templates")
}
register<GenerateTask>("generateKvkZoekenClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/kvk/zoeken-openapi.yaml")
outputDir.set("$rootDir/src/generated/kvk/zoeken/java")
modelPackage.set("net.atos.client.kvk.zoeken.model.generated")
}
register<GenerateTask>("generateKvkBasisProfielClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/kvk/basisprofiel-openapi.yaml")
outputDir.set("$rootDir/src/generated/kvk/basisprofiel/java")
modelPackage.set("net.atos.client.kvk.basisprofiel.model.generated")
}
register<GenerateTask>("generateKvkVestigingsProfielClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/kvk/vestigingsprofiel-openapi.yaml")
outputDir.set("$rootDir/src/generated/kvk/vestigingsprofiel/java")
modelPackage.set("net.atos.client.kvk.vestigingsprofiel.model.generated")
}
register<GenerateTask>("generateBrpClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/brp/brp-openapi.yaml")
outputDir.set("$rootDir/src/generated/brp/java")
modelPackage.set("net.atos.client.brp.model.generated")
}
register<GenerateTask>("generateBagClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/bag/bag-openapi.yaml")
outputDir.set("$rootDir/src/generated/bag/java")
modelPackage.set("net.atos.client.bag.model.generated")
// we need to use the java8-localdatetime date library for this client
// or else certain date time fields for this client cannot be deserialized
configOptions.set(
mapOf(
"library" to "microprofile",
"microprofileRestClientVersion" to libs.versions.microprofile.rest.client.get(),
"sourceFolder" to "",
"dateLibrary" to "java8-localdatetime",
"disallowAdditionalPropertiesIfNotPresent" to "false",
"openApiNullable" to "false",
"useJakartaEe" to "true"
)
)
}
register<GenerateTask>("generateKlantenClient") {
// disabled because (at least with our current settings) this results
// in uncompilable generated Java code
// this task was not enabled in the original Maven build either;
// these model files were added to the code base manually instead
isEnabled = false
inputSpec.set("$rootDir/src/main/resources/api-specs/klanten/klanten-openapi.yaml")
outputDir.set("$rootDir/src/generated/klanten/java")
modelPackage.set("net.atos.client.klanten.model.generated")
}
register<GenerateTask>("generateZgwBrcClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/zgw/brc-openapi.yaml")
outputDir.set("$rootDir/src/generated/zgw/brc/java")
modelPackage.set("net.atos.client.zgw.brc.model.generated")
}
register<GenerateTask>("generateZgwDrcClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/zgw/drc-openapi.yaml")
outputDir.set("$rootDir/src/generated/zgw/drc/java")
// this OpenAPI spec contains a schema validation error: `schema: null`
// so we disable the schema validation for this spec until this is fixed in a future version of this spec
validateSpec.set(false)
modelPackage.set("net.atos.client.zgw.drc.model.generated")
}
register<GenerateTask>("generateZgwZrcClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/zgw/zrc-openapi.yaml")
outputDir.set("$rootDir/src/generated/zgw/zrc/java")
modelPackage.set("net.atos.client.zgw.zrc.model.generated")
}
register<GenerateTask>("generateZgwZtcClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/zgw/ztc-openapi.yaml")
outputDir.set("$rootDir/src/generated/zgw/ztc/java")
modelPackage.set("net.atos.client.zgw.ztc.model.generated")
}
register<GenerateTask>("generateOrObjectsClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/or/objects-openapi.yaml")
outputDir.set("$rootDir/src/generated/or/objects/java")
modelPackage.set("net.atos.client.or.objects.model.generated")
}
register<GenerateTask>("generateOrObjectTypesClient") {
inputSpec.set("$rootDir/src/main/resources/api-specs/or/objecttypes-openapi.yaml")
outputDir.set("$rootDir/src/generated/or/objecttypes/java")
modelPackage.set("net.atos.client.or.objecttypes.model.generated")
}
register("generateJavaClients") {
dependsOn(
generateJsonSchema2Pojo,
"generateKvkZoekenClient",
"generateKvkBasisProfielClient",
"generateKvkVestigingsProfielClient",
"generateBrpClient",
"generateBagClient",
"generateKlantenClient",
"generateZgwBrcClient",
"generateZgwDrcClient",
"generateZgwZrcClient",
"generateZgwZtcClient",
"generateOrObjectsClient",
"generateOrObjectTypesClient"
)
}
getByName("npmInstall") {
inputs.file("src/main/app/package.json")
outputs.dir("src/main/app/node_modules")
}
register<NpmTask>("npmRunBuild") {
dependsOn("npmInstall")
dependsOn("generateOpenApiSpec")
npmCommand.set(listOf("run", "build"))
inputs.files(fileTree("src/main/app/node_modules"))
inputs.files(fileTree("src/main/app/src"))
outputs.files(fileTree("src/main/app/dist/zaakafhandelcomponent"))
outputs.files(fileTree("src/main/app/src/generated/types"))
outputs.cacheIf { true }
}
register<NpmTask>("npmRunTest") {
dependsOn("npmRunBuild")
npmCommand.set(listOf("run", "test"))
inputs.files(fileTree("src/main/app/node_modules"))
inputs.files(fileTree("src/main/app/src"))
// directory used by the Jest reporter(s) that we have configured
outputs.dir("src/main/app/reports")
}
register<NpmTask>("npmRunTestCoverage") {
dependsOn("npmRunTest")
npmCommand.set(listOf("run", "test:report"))
outputs.dir("src/main/app/coverage")
}
register<Exec>("buildDockerImage") {
dependsOn("generateWildflyBootableJar")
inputs.file("Dockerfile")
inputs.file("target/zaakafhandelcomponent.jar")
inputs.files(fileTree("certificates"))
workingDir(".")
commandLine("scripts/docker/build-docker-image.sh", "-v", versionNumber, "-b", branchName, "-c", commitHash, "-t", zacDockerImage)
}
register<Copy>("copyJacocoAgentForItest") {
description = "Copies and renames the JaCoCo agent runtime JAR file for instrumentation during the integration tests"
from(configurations.getByName("jacocoAgentJarForItest"))
// simply rename the JaCoCo agent runtime JAR file name to strip away the version number
rename {
"org.jacoco.agent-runtime.jar"
}
into(layout.buildDirectory.dir("jacoco/itest/jacoco-agent"))
}
register<Test>("itest") {
dependsOn("buildDockerImage")
testClassesDirs = sourceSets["itest"].output.classesDirs
classpath = sourceSets["itest"].runtimeClasspath
systemProperty("zacDockerImage", zacDockerImage)
// do not use the Gradle build cache for this task
outputs.cacheIf { false }
}
register<JacocoReport>("jacocoIntegrationTestReport") {
dependsOn("itest")
description = "Generates code coverage report for the integration tests"
val resultFile = layout.buildDirectory.file("jacoco/itest/jacoco-report/jacoco-it.exec").orNull
inputs.files(resultFile)
executionData.setFrom(resultFile)
// tell JaCoCo to report on our code base
sourceSets(sourceSets["main"])
reports {
xml.required = true
html.required = false
}
// do not use the Gradle build cache for this task
outputs.cacheIf { false }
outputs.dir(layout.buildDirectory.dir("reports/jacoco/jacocoIntegrationTestReport"))
}
register<Maven>("generateWildflyBootableJar") {
dependsOn("war")
execGoal("wildfly:package")
val wildflyResources = srcMainResources.dir("wildfly")
inputs.files(wildflyResources.asFileTree)
inputs.file(layout.buildDirectory.file("libs/zaakafhandelcomponent.war"))
inputs.file(layout.projectDirectory.file("pom.xml"))
inputs.file(wildflyResources.file("configure-wildfly.cli"))
inputs.file(wildflyResources.file("deploy-zaakafhandelcomponent.cli"))
outputs.dir(layout.projectDirectory.dir("target"))
}
register<Maven>("mavenClean") {
execGoal("clean")
}
}
abstract class Maven : Exec() {
// Simple function to invoke a maven goal, dependent on the os, with optional arguments
fun execGoal(goal: String, vararg args: String) = commandLine(
if (System.getProperty("os.name").lowercase(Locale.ROOT).contains("windows")) {
"./mvnw.cmd"
} else {
"./mvnw"
},
goal,
*args
)
}