-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.gradle
More file actions
529 lines (431 loc) · 20.4 KB
/
build.gradle
File metadata and controls
529 lines (431 loc) · 20.4 KB
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
import org.flywaydb.gradle.task.FlywayMigrateTask
import uk.gov.hmcts.rse.AuthMode
buildscript {
dependencies {
classpath("org.flywaydb:flyway-database-postgresql:12.4.0")
}
}
plugins {
id 'application'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.springframework.boot' version '3.5.14'
id 'uk.gov.hmcts.java' version '0.12.68'
id 'org.owasp.dependencycheck' version '12.2.1'
id 'com.github.ben-manes.versions' version '0.54.0'
id 'org.sonarqube' version '7.2.3.7755'
id 'jacoco'
id 'checkstyle'
id 'au.com.dius.pact' version '4.7.0'
id 'info.solidsoft.pitest' version '1.19.0'
id 'net.serenity-bdd.serenity-gradle-plugin' version '5.3.9'
id 'com.github.hmcts.rse-cft-lib' version '0.19.2110'
id 'org.flywaydb.flyway' version '12.4.0'
}
if (!project.hasProperty('runList')) {
project.ext.runList = 'main'
}
group = 'uk.gov.hmcts.reform.em.annotation'
version ='1.0.0'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
application {
mainClass = 'uk.gov.hmcts.reform.em.annotation.Application'
}
def versions = [
postgresql : '42.7.10',
springSecurity : '6.5.10',
fasterXmlJackson : '2.21.2',
pitest : '1.5.1',
gradlePitest : '1.3.0',
sonarPitest : '0.5',
serenity : '5.3.10',
pact_version : '4.6.20',
hibernate : '6.6.49.Final',
logging : '8.0.0',
junit5 : '6.0.3',
log4JVersion : '2.20.0',
mapstruct : '1.6.3',
]
sourceSets {
aat {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
test {
java.srcDir 'src/test/java'
}
integrationTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
}
configurations {
aatImplementation.extendsFrom(testImplementation)
aatRuntimeOnly.extendsFrom(testRuntimeOnly)
}
configurations.configureEach {
exclude group: 'com.vaadin.external.google', module: 'android-json'
exclude group: 'org.springframework.security', module: 'spring-security-rsa'
}
dependencies {
def withoutStuff = {
exclude group: 'com.sun.xml.bind', module: 'jaxb-osgi'
exclude group: 'com.github.hmcts.java-logging', module: 'java-logging-spring'
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-actuator'
}
def withoutPactExtras = {
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-io'
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-io'
exclude group: 'org.eclipse.jetty.alpn', module: 'alpn-api'
}
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation'
implementation group: 'org.springframework.boot', name: 'spring-boot-autoconfigure'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: '4.3.2'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-openfeign', version: '4.3.2'
implementation group:'com.fasterxml.jackson.datatype', name: 'jackson-datatype-json-org', version: versions.fasterXmlJackson
implementation group:'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hppc', version: versions.fasterXmlJackson
implementation group:'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: versions.fasterXmlJackson
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate6', version: versions.fasterXmlJackson
implementation group:'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.21'
implementation group:'com.fasterxml.jackson.core', name: 'jackson-databind',version: versions.fasterXmlJackson
implementation group:'com.fasterxml.jackson.core', name: 'jackson-core', version: versions.fasterXmlJackson
implementation group:'com.fasterxml.jackson.module', name: 'jackson-module-blackbird', version: versions.fasterXmlJackson
implementation group: 'org.zalando', name: 'problem-spring-web', version: '0.29.1'
implementation group: 'org.zalando', name: 'jackson-datatype-problem', version: '0.27.1'
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.8.17'
implementation group: 'com.google.guava', name: 'guava', version: '33.6.0-jre'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '12.4.0'
runtimeOnly group: 'org.flywaydb', name: 'flyway-database-postgresql', version: '12.4.0'
implementation group: 'org.postgresql', name: 'postgresql', version: versions.postgresql
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.20.0'
implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.11.0'
implementation group: 'commons-validator', name: 'commons-validator', version: '1.10.1'
implementation group: 'org.ehcache', name: 'ehcache', version: '3.12.0'
implementation group:'org.hibernate.orm', name: 'hibernate-core', version: versions.hibernate
implementation group:'org.hibernate.orm', name: 'hibernate-jcache', version: versions.hibernate
implementation group:'org.hibernate.orm', name: 'hibernate-envers', version: versions.hibernate
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.logging
implementation group: 'org.mapstruct', name: 'mapstruct', version: versions.mapstruct
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-resource-server', version: versions.springSecurity
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-client', version: versions.springSecurity
implementation group: 'org.springframework.security', name: 'spring-security-web', version: versions.springSecurity
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-jose', version: versions.springSecurity
implementation group: 'org.springframework.security', name: 'spring-security-core', version: versions.springSecurity
implementation group: 'org.springframework.security', name: 'spring-security-config', version: versions.springSecurity
implementation group: 'org.springframework.security', name: 'spring-security-core', version: versions.springSecurity
implementation group: 'com.github.hmcts', name: 'core-case-data-store-client', version: '5.2.0'
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.3.3'
implementation group: 'com.github.hmcts', name: 'idam-java-client', version: '3.0.5'
implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '3.0.0'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '4.3.2'
implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.46'
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.46'
annotationProcessor group: 'org.mapstruct', name: 'mapstruct-processor', version: versions.mapstruct
annotationProcessor group:'org.hibernate.orm', name: 'hibernate-jpamodelgen', version: versions.hibernate
annotationProcessor group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', withoutStuff
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
testImplementation group: 'com.warrenstrange', name: 'googleauth', version: '1.5.0'
aatRuntimeOnly group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '4.0.5'
aatRuntimeOnly group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '4.0.7'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version:versions.junit5
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junit5
//pact contract testing
testImplementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: versions.serenity
testImplementation group: 'net.serenity-bdd', name: 'serenity-spring', version: versions.serenity
testImplementation group: 'net.serenity-bdd', name: 'serenity-single-page-report', version: versions.serenity
testImplementation group: 'net.serenity-bdd', name: 'serenity-junit5', version: versions.serenity
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.5.32'
testImplementation group: 'ch.qos.logback', name: 'logback-core', version: '1.5.32'
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.10', classifier: 'all', {
exclude group: 'commons-io', module: 'commons-io'
exclude group: 'org.apache.commons', module: 'commons-lang3'
exclude group: 'ch.qos.logback', module: 'logback-classic'
exclude group: 'ch.qos.logback', module: 'logback-core'
}
testImplementation group: 'org.testcontainers', name: 'postgresql', version: '1.21.4'
testImplementation group: 'com.h2database', name: 'h2', version: '2.4.240'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '5.2.0'
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit', version: versions.pact_version, withoutPactExtras
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: versions.pact_version, withoutPactExtras
contractTestImplementation group: 'au.com.dius.pact', name: 'provider', version: versions.pact_version
contractTestImplementation group: 'au.com.dius.pact.provider', name: 'junit5', version: versions.pact_version
contractTestImplementation group: 'au.com.dius.pact.provider', name: 'spring6', version: versions.pact_version
contractTestImplementation group: 'au.com.dius.pact.provider', name: 'junit5spring', version: versions.pact_version
contractTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version:versions.junit5
contractTestRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:versions.junit5
aatImplementation group: 'org.json', name: 'json', version: '20250517'
aatImplementation group: 'com.github.hmcts', name: 'em-test-helper', version:'3.0.0'
contractTestImplementation sourceSets.main.runtimeClasspath
contractTestImplementation sourceSets.test.runtimeClasspath
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
cftlibImplementation 'org.springframework.boot:spring-boot-devtools'
}
processAatResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
processIntegrationTestResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
dependencyManagement {
dependencies {
//CVE-2022-23437
dependencySet(group: 'xerces', version: '2.12.2') {
entry 'xercesImpl'
}
//CVE-2020-13956
dependencySet(group: 'org.apache.httpcomponents', version: '4.5.14') {
entry 'fluent-hc'
}
//CVE-2023-6378
dependencySet(group: 'ch.qos.logback', version: '1.5.32') {
entry 'logback-classic'
entry 'logback-core'
}
dependencySet(group: 'org.junit.platform', version: '6.0.3') {
entry 'junit-platform-commons'
entry 'junit-platform-engine'
entry 'junit-platform-launcher'
}
}
}
tasks.register('integration', Test) {
failFast = true
useJUnitPlatform()
description = "Runs integration tests"
group = "Verification"
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}
bootJar {
getArchiveFileName().set(provider {
'em-annotation-app.jar'
})
manifest {
attributes 'Implementation-Title': project.name, 'Implementation-Version': project.version
}
}
def coverageExclusionList = [
'**uk/gov/hmcts/reform/em/annotation/Application*',
'**uk/gov/hmcts/reform/em/annotation/domain/*',
'**uk/gov/hmcts/reform/em/annotation/service/dto/*',
'**uk/gov/hmcts/reform/em/annotation/info/*',
'**uk/gov/hmcts/reform/em/annotation/data/migration/PendingMigrationScriptException*',
'**uk/gov/hmcts/reform/em/annotation/data/migration/FlywayNoOpStrategy*',
'**uk/gov/hmcts/reform/em/annotation/config/FlywayConfiguration*'
]
jacocoTestReport {
dependsOn test, integration
executionData(test, integration)
reports {
xml.required = true
csv.required = false
xml.outputLocation = layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml") }
}
pitest {
targetClasses = ['uk.gov.hmcts.reform.em.annotation.*']
excludedClasses = [
'uk.gov.hmcts.reform.em.annotation.config.*',
'uk.gov.hmcts.reform.em.annotation.info.*',
'uk.gov.hmcts.reform.em.annotation.Application.java',
'uk.gov.hmcts.reform.em.annotation.service.util.*'
]
enableDefaultIncrementalAnalysis = true
historyInputLocation = 'build/reports/pitest/fastermutationtesting'
historyOutputLocation ='build/reports/pitest/fastermutationtestingoutput'
threads = 15
testSourceSets = [sourceSets.test]
mainSourceSets = [sourceSets.main]
fileExtensionsToFilter.addAll('xml','json')
outputFormats = ['XML', 'HTML','CSV']
mutationThreshold = 5
coverageThreshold = 0
jvmArgs = ['-Xms1G','-Xmx3G']
timestampedReports = false
failWhenNoMutations = false
detectInlinedCode = true
junit5PluginVersion = '1.2.1'
pitestVersion = '1.17.3'
}
sonarqube {
properties {
property "sonar.projectName", "${rootProject.name}"
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.outputLocation}"
property "sonar.exclusions", coverageExclusionList.join(", ")
property "sonar.test.exclusions", "**/test/**"
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
}
}
project.tasks['sonarqube'].group = "Verification"
project.tasks['sonarqube'].dependsOn test, jacocoTestReport
configurations {
contractTestImplementation.extendsFrom testImplementation
contractTestRuntimeOnly.extendsFrom testRuntimeOnly
}
checkstyle {
maxWarnings = 0
toolVersion = '13.4.0'
reportsDir = layout.buildDirectory.file('reports/checkstyle').get().asFile
// need to set configDir to rootDir otherwise submodule will use submodule/config/checkstyle
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
checkstyleMain.shouldRunAfter(compileJava)
test.shouldRunAfter(checkstyleTest)
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
test {
useJUnitPlatform()
}
tasks.register('functional', Test) {
group = 'Delivery pipeline'
description = 'Executes functional tests'
setTestClassesDirs(sourceSets.aat.output.classesDirs)
setClasspath(sourceSets.aat.runtimeClasspath)
include "uk/gov/hmcts/reform/em/annotation/functional/**"
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
useJUnitPlatform()
}
// Serenity Reporting
// functional.finalizedBy(aggregate)
tasks.register('smoke', Test) {
group = 'Delivery pipeline'
description = 'Executes non-destructive smoke tests'
setTestClassesDirs(sourceSets.aat.output.classesDirs)
setClasspath(sourceSets.aat.runtimeClasspath)
include "uk/gov/hmcts/reform/em/annotation/smoke/**"
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
useJUnitPlatform()
}
project.ext {
pacticipantVersion = getCheckedOutGitCommitHash()
}
static def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}
tasks.register('contract', Test) {
group = 'Delivery pipeline'
description = 'Runs the consumer Pact tests'
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
include '**/consumer/**'
systemProperty 'pact.rootDir', "pacts"
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
tasks.register('fortifyScan', JavaExec) {
mainClass = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
pact {
broker {
pactBrokerUrl = System.getenv("PACT_BROKER_FULL_URL") ?: 'http://localhost:80'
}
publish {
pactBrokerUrl = System.getenv("PACT_BROKER_FULL_URL") ?: 'http://localhost:80'
pactDirectory = 'pacts'
tags = [System.getenv("PACT_BRANCH_NAME") ?: 'Dev']
consumerBranch = System.getenv("PACT_BRANCH_NAME") ?: 'Dev'
version = project.pacticipantVersion
}
}
pactPublish {
pactPublish = project.pact.publish
}
tasks.register('runAndPublishConsumerPactTests', Test) {
logger.lifecycle("Runs pact Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang=ALL-UNNAMED']
useJUnitPlatform()
}
runAndPublishConsumerPactTests.dependsOn contract
runAndPublishConsumerPactTests.finalizedBy pactPublish
tasks.register('providerContractTests', Test) {
description = 'Runs ONLY the provider Pact verification tests.'
group = 'Verification'
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
include '**/provider/**'
}
// Centralized Pact system property setup for all Test tasks
tasks.withType(Test).configureEach { t ->
// Logging setup
testLogging {
exceptionFormat = 'full'
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
events "passed", "skipped", "failed", "standard_out", "standard_error"
}
if (project.hasProperty('pact.verifier.publishResults')) {
systemProperty 'pact.verifier.publishResults', project.property('pact.verifier.publishResults')
}
if (project.hasProperty('pact.provider.version')) {
systemProperty 'pact.provider.version', project.property('pact.provider.version')
} else {
systemProperty 'pact.provider.version', project.pacticipantVersion
}
if (project.hasProperty('pact.provider.branch')) {
systemProperty 'pact.provider.branch', project.property('pact.provider.branch')
} else {
systemProperty 'pact.provider.branch', System.getenv("PACT_BRANCH_NAME") ?: "Dev"
}
doFirst {
println "--- Running '${t.name}' ---"
println "System properties for this run: ${systemProperties}"
}
}
tasks.register('runProviderPactVerification') {
description = 'Entry point for Jenkins to run provider contract tests.'
group = 'Verification'
dependsOn tasks.named('providerContractTests')
}
bootWithCCD {
authMode = AuthMode.Local
environment 'RSE_LIB_ADDITIONAL_DATABASES', 'emannotationapp'
environment 'DATA_STORE_S2S_AUTHORISED_SERVICES', 'ccd_gw,em_annotation_app'
environment 'DOC_ASSEMBLY_SERVER_PORT', '8081'
}
serenity {
reports = ["single-page-html"]
}
dependencyCheck {
suppressionFile = 'config/owasp/dependency-check-suppressions.xml'
}
compileJava.dependsOn processResources
flyway {
url = System.getenv('FLYWAY_URL')
user = System.getenv('FLYWAY_USER')
password = System.getenv('FLYWAY_PASSWORD')
baselineOnMigrate = true
baselineVersion = '1'
}
tasks.register('migratePostgresDatabase', FlywayMigrateTask) {
baselineOnMigrate = true
if (project.hasProperty("dburl")) {
url = "jdbc:postgresql://${dburl}"
}
}