-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
536 lines (441 loc) · 21 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
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
buildscript {
dependencies {
classpath("org.flywaydb:flyway-database-postgresql:10.21.0")
}
}
plugins {
id 'application'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.springframework.boot' version '3.3.5'
id 'uk.gov.hmcts.java' version '0.12.63'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonarqube' version '5.1.0.4882'
id 'jacoco'
id 'checkstyle'
id 'au.com.dius.pact' version '4.2.14'
id "info.solidsoft.pitest" version '1.15.0'
id 'org.owasp.dependencycheck' version '11.1.0'
id 'com.github.hmcts.rse-cft-lib' version '0.19.1456'
id 'org.flywaydb.flyway' version '10.21.0'
id 'net.serenity-bdd.serenity-gradle-plugin' version '3.0.0'
}
apply plugin: 'java'
apply plugin: 'idea'
if (!project.hasProperty('runList')) {
project.ext.runList = 'main'
}
group 'uk.gov.hmcts.reform.em.stitching'
version '0.1.0'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
mainClassName = 'uk.gov.hmcts.reform.em.stitching.Application'
configurations {
aatImplementation.extendsFrom(testImplementation)
aatRuntimeOnly.extendsFrom(testRuntimeOnly)
}
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://repo.spring.io/milestone/'}
}
def versions = [
serenity : '3.4.2',
serenityreporter : '3.4.2',
serenityRestAssured : '3.4.2',
pact_version : '4.0.10',
springSecurity : '6.3.4',
springcloud : '4.1.4',
fasterXmlJackson : '2.18.1',
mapstruct : '1.6.3',
hibernate : '6.6.2.Final',
jupiter : '5.11.3',
postgresql : '42.7.4',
shedlock : '5.16.0',
lombok : '1.18.34',
]
pitest {
targetClasses = ['uk.gov.hmcts.reform.em.stitching.*']
excludedClasses = [
'uk.gov.hmcts.reform.em.stitching.appinsights.*' ,
'uk.gov.hmcts.reform.em.stitching.info.*',
'uk.gov.hmcts.reform.em.stitching.Application.java'
]
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
}
project.tasks['sonarqube'].group = "Verification"
sourceSets {
aat {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
}
configurations.all {
exclude group: 'com.vaadin.external.google', module: 'android-json'
exclude group: 'org.springframework.retry', module: 'spring-retry'
exclude group: 'org.springframework.security', module: 'spring-security-rsa'
exclude group: 'org.codehaus.jettison', module: 'jettison'
}
dependencies {
def withoutStuff = {
exclude group: 'com.vaadin.external.google', module: 'android-json'
exclude group: 'com.sun.xml.bind', module: 'jaxb-osgi'
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-security'
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-test'
}
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'
}
def withoutCVE202011987 = {
exclude group: 'org.apache.xmlgraphics', module: 'batik-all'
}
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-jdbc'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-batch'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: versions.springcloud
implementation group: 'com.google.guava', name: 'guava', version: '33.3.1-jre'
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-oauth2-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.squareup.okhttp3', name: 'okhttp', version: '4.12.0'
implementation group:'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5-jakarta', version: versions.fasterXmlJackson
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.3'
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.6.0'
implementation group: 'org.apache.httpcomponents', name : 'httpclient', version: '4.5.14'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '10.21.0'
runtimeOnly group: 'org.flywaydb', name: 'flyway-database-postgresql', version: '10.21.0'
implementation group: 'org.mapstruct', name: 'mapstruct-jdk8', version: versions.mapstruct
implementation group: 'org.postgresql', name: 'postgresql', version: versions.postgresql
implementation group: 'org.ehcache', name:'ehcache', version: '3.10.8'
implementation group:'org.hibernate', name: 'hibernate-core', version: versions.hibernate
implementation group:'org.hibernate', name: 'hibernate-jcache', version: versions.hibernate
implementation group:'org.hibernate', name: 'hibernate-envers', version: versions.hibernate
implementation group: 'pl.touk', name: 'throwing-function', version: '1.3'
implementation group: 'com.zaxxer', name: 'HikariCP', version: '6.1.0'
implementation group: "org.apache.commons", name: "commons-lang3", version: "3.17.0"
implementation group: "commons-validator", name: "commons-validator", version: "1.9.0"
implementation group: 'org.apache.pdfbox', name: 'pdfbox', version: "3.0.2"
implementation group: "net.javacrumbs.shedlock", name: "shedlock-spring", version: versions.shedlock
implementation group: "net.javacrumbs.shedlock", name: "shedlock-provider-jdbc-template", version: versions.shedlock
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.3.0', withoutCVE202011987
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.2.0'
implementation group: 'com.github.hmcts', name: 'idam-java-client', version: '3.0.3'
implementation group: 'com.github.hmcts', name: 'ccd-case-document-am-client', version: '1.7.3'
implementation group: 'com.github.hmcts', name: 'auth-checker-lib', version: '3.0.2', withoutStuff
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: '6.1.7'
implementation group: 'com.vladmihalcea', name: 'hibernate-types-60', version: '2.21.1'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '4.1.3'
implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: '13.5'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
implementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
implementation group: 'org.mapstruct', name: 'mapstruct', version: versions.mapstruct
annotationProcessor group: 'org.mapstruct', name: 'mapstruct-processor', version: versions.mapstruct
annotationProcessor group:'org.hibernate', name: 'hibernate-jpamodelgen', version: versions.hibernate
annotationProcessor group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', withoutStuff
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
aatAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', withoutStuff
testImplementation group: 'com.github.gmazzo', name: 'okhttp-mock', version: '2.0.0'
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
testImplementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: versions.serenityRestAssured, withoutStuff
testImplementation group: 'net.serenity-bdd', name: 'serenity-core', version: versions.serenity, withoutStuff
testImplementation group: 'net.serenity-bdd', name: 'serenity-junit', 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.serenityreporter
testRuntimeOnly group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.11.3'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.jupiter
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.jupiter
testImplementation group: 'org.testcontainers', name: 'postgresql', version: '1.20.3'
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.5', classifier: 'all'
aatRuntimeOnly group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '4.0.2'
aatRuntimeOnly group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '4.0.5'
//pact contract testing
contractTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.jupiter
contractTestRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.jupiter
contractTestImplementation group: 'au.com.dius', name: 'pact-jvm-consumer-junit', version: versions.pact_version, withoutPactExtras
contractTestImplementation group: 'au.com.dius', name: 'pact-jvm-consumer-junit5', version: versions.pact_version, withoutPactExtras
contractTestImplementation group: 'au.com.dius', name: 'pact-jvm-consumer-java8', version: versions.pact_version, withoutPactExtras
implementation group: 'au.com.dius', name: 'pact-jvm-consumer', version: versions.pact_version, withoutPactExtras
contractTestImplementation sourceSets.main.runtimeClasspath
contractTestImplementation sourceSets.test.runtimeClasspath
contractTestImplementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
aatImplementation group: 'com.github.hmcts', name: 'em-test-helper', version: '2.0.9', withoutStuff
cftlibImplementation 'org.springframework.boot:spring-boot-devtools'
}
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-35116
dependencySet(group: 'com.fasterxml.jackson.core', version: versions.fasterXmlJackson) {
entry 'jackson-databind'
entry 'jackson-annotations'
entry 'jackson-core'
}
//CVE-2024-26308, CVE-2024-25710
dependencySet(group: 'org.apache.commons', version: '1.27.1') {
entry 'commons-compress'
}
//CVE-2022-45688, CVE-2023-5072
dependencySet(group: 'org.json', version: '20240303') {
entry 'json'
}
dependencySet(group: 'org.junit.platform', version: '1.11.3') {
entry 'junit-platform-commons'
}
}
}
bootJar {
getArchiveFileName().set(provider {
'rpa-em-stitching-api.jar'
})
manifest {
attributes 'Implementation-Title': project.name, 'Implementation-Version': project.version
}
}
dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
// https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/configuration.html
dependencyCheck {
suppressionFile = 'config/owasp/dependency-check-suppressions.xml'
}
checkstyle {
maxWarnings = 0
toolVersion = '10.20.1'
// need to set configDir to rootDir otherwise submodule will use submodule/config/checkstyle
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
def coverageExclusionList = [
'**uk/gov/hmcts/reform/em/stitching/Application*',
'**uk/gov/hmcts/reform/em/stitching/appinsights/*',
'**uk/gov/hmcts/reform/em/stitching/config/**/*',
'**uk/gov/hmcts/reform/em/stitching/info/*',
'**uk/gov/hmcts/reform/em/stitching/service/mapper/*',
'**uk/gov/hmcts/reform/em/stitching/domain/*',
'**uk/gov/hmcts/reform/em/stitching/service/dto/*',
'**uk/gov/hmcts/reform/em/stitching/data/migration/PendingMigrationScriptException*',
'**uk/gov/hmcts/reform/em/stitching/data/migration/FlywayNoOpStrategy*',
'**uk/gov/hmcts/reform/em/stitching/batch/DocumentTaskItemProcessor*'
]
jacocoTestReport {
executionData(test)
reports {
xml.required = true
csv.required = false
xml.outputLocation = file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
project.tasks['sonarqube'].dependsOn test, jacocoTestReport
sonarqube {
properties {
property "sonar.projectName", "EM Stitching API"
property "sonar.projectKey", "em-stitching-api"
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.outputLocation}"
property "sonar.exclusions", coverageExclusionList.join(", ")
property "sonar.tests", "src/test/java"
property "sonar.issue.ignore.multicriteria", "e1"
property "sonar.issue.ignore.multicriteria.e1.ruleKey", "java:S2629"
property "sonar.issue.ignore.multicriteria.e1.resourceKey", "src/main/java/uk/gov/hmcts/reform/em/stitching/**"
}
}
// https://github.com/gradle/gradle/issues/16791
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
test {
useJUnitPlatform()
}
task functional(type: Test) {
group = 'Delivery pipeline'
description = 'Executes functional tests'
setTestClassesDirs(sourceSets.aat.output.classesDirs)
setClasspath(sourceSets.aat.runtimeClasspath)
include "uk/gov/hmcts/reform/em/stitching/functional/**"
testLogging {
exceptionFormat = 'full'
}
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
// Serenity Single page Reports
// functional.finalizedBy(aggregate)
task smoke(type: 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/stitching/smoke/**"
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
compileJava.dependsOn processResources
task contract(type: Test) {
group = 'Delivery pipeline'
description = 'Runs the consumer Pact tests'
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
include "uk/gov/hmcts/reform/em/stitching/**"
systemProperty 'pact.rootDir', "pacts"
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
task runAndPublishConsumerPactTests(type: Test){
logger.lifecycle("Runs pact Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
task fortifyScan(type: JavaExec) {
mainClass = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
runAndPublishConsumerPactTests.dependsOn contract
runAndPublishConsumerPactTests.finalizedBy pactPublish
project.ext {
pactVersion = getCheckedOutGitCommitHash()
}
static def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}
serenity {
reports = ["single-page-html"]
}
pact {
publish {
pactDirectory = 'pacts'
pactBrokerUrl = System.getenv("PACT_BROKER_FULL_URL") ?: 'http://localhost:80'
version = project.pactVersion
}
}
task loadEnvSecrets() {
doLast {
if (!project.file('./.aat-env').exists()) {
new ByteArrayOutputStream().withStream { os ->
exec {
commandLine 'az', 'keyvault', 'secret', 'show', '--vault-name', 'em-stitching-aat', '-o', 'tsv', '--query', 'value', '--name', 'em-stitching-dot-env'
standardOutput = os
}
project.file('./.aat-env').write(new String(os.toString().replace('\n', '').decodeBase64(), java.nio.charset.StandardCharsets.UTF_8))
}
}
}
}
task reloadEnvSecrets(group: 'ccd tasks', dependsOn: [loadEnvSecrets]) {
doFirst {
if (project.file('./.aat-env').exists()) {
project.file('./.aat-env').delete()
}
}
}
bootRun {
doFirst() {
if (project.file('./.aat-env').exists()) {
project.file('./.aat-env').readLines().each() {
def index = it.indexOf("=")
def key = it.substring(0, index)
def value = it.substring(index + 1)
environment key, value
}
}
}
}
functional {
doFirst() {
if (project.file('./.aat-env').exists()) {
project.file('./.aat-env').readLines().each() {
def index = it.indexOf("=")
def key = it.substring(0, index)
def value = it.substring(index + 1)
environment key, value
}
}
}
}
bootWithCCD {
dependsOn(loadEnvSecrets)
doFirst() {
project.file('./.aat-env').readLines().each() {
def index = it.indexOf("=")
def key = it.substring(0, index)
def value = it.substring(index + 1)
environment key, value
}
exec {
commandLine 'docker', 'compose', '-f', 'src/cftlib/resources/docker-compose-local.yml', '-p', 'cftlib', 'up', '-d'
}
}
environment 'RSE_LIB_ADDITIONAL_DATABASES', 'emstitch,evidence'
environment 'DATA_STORE_S2S_AUTHORISED_SERVICES', 'ccd_gw,ccd_data,ccd_ps,aac_manage_case_assignment,ccd_case_document_am_api,am_role_assignment_service,hmc_cft_hearing_service,prl_citizen_frontend,xui_webapp,em_ccd_orchestrator'
environment 'CASE_DOCUMENT_S2S_AUTHORISED_SERVICES', 'em_gw,em_stitching_api,ccd_case_document_am_api,ccd_gw,xui_webapp,ccd_data'
environment 'CASE_DOCUMENT_AM_API_S2S_SECRET','${CASE_DOCUMENT_AM_API_S2S_SECRET}'
environment 'CCD_DOCUMENT_URL_PATTERN', 'https?://localhost:4603/documents/[A-Za-z0-9-]+(?:/binary)?'
environment 'DM_STORE_BASE_URL', 'http://localhost:4603'
environment 'DOC_ASSEMBLY_SERVER_PORT', '8081'
authMode = uk.gov.hmcts.rse.AuthMode.Local
}
// exclude the logback binding is coming in via cftlib
configurations.cftlibTestImplementation {
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
flyway {
url = System.getenv('FLYWAY_URL')
user = System.getenv('FLYWAY_USER')
password = System.getenv('FLYWAY_PASSWORD')
baselineOnMigrate = true
baselineVersion = '1'
}
task migratePostgresDatabase(type: org.flywaydb.gradle.task.FlywayMigrateTask) {
baselineOnMigrate = true
if (project.hasProperty("dburl")) {
url = "jdbc:postgresql://${dburl}"
}
}