-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
482 lines (396 loc) · 17.8 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
plugins {
id 'application'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.springframework.boot' version '3.4.1'
id 'uk.gov.hmcts.java' version '0.12.63'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonarqube' version '6.0.1.5171'
id 'jacoco'
id 'checkstyle'
id 'au.com.dius.pact' version '4.6.16'
id "info.solidsoft.pitest" version '1.15.0'
id 'org.owasp.dependencycheck' version '11.1.1'
id 'net.serenity-bdd.serenity-gradle-plugin' version '4.2.8'
}
apply plugin: 'idea'
if (!project.hasProperty('runList')) {
project.ext.runList = 'main'
}
group 'uk.gov.hmcts.reform.em.orchestrator'
version '1.0.0'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
mainClassName = 'uk.gov.hmcts.reform.em.orchestrator.Application'
configurations {
aatImplementation.extendsFrom(testImplementation)
aatRuntimeOnly.extendsFrom(testRuntimeOnly)
}
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://repo.spring.io/milestone/'}
}
def versions = [
serenity : '4.2.9',
pact_version : '4.6.16',
mockito : '5.14.2',
jupiter : '5.11.4',
poi : '5.3.0',
springSecurity : '6.4.2',
okhttp3 : '4.12.0',
fasterXmlJackson : '2.18.2'
]
sourceSets {
aat {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
test {
java.srcDir 'src/test/java'
}
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
}
configurations.all {
exclude group: 'com.vaadin.external.google', module: 'android-json'
exclude group: 'org.glassfish', module: 'jakarta.el'
exclude group: 'org.springframework.retry', module: 'spring-retry'
exclude group: 'org.springframework.security', module: 'spring-security-rsa'
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-security'
exclude group: 'com.ibm.icu', module: 'icu4j'
exclude group: 'org.codehaus.jettison', module: 'jettison'
}
dependencies {
def withoutStuff = {
exclude group: 'com.sun.xml.bind', module: 'jaxb-osgi'
}
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-batch'
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: 'com.google.guava', name: 'guava', version: '33.4.0-jre'
implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.36'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: versions.okhttp3
implementation group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: versions.okhttp3
implementation group: "commons-io", name: "commons-io", version: "2.18.0"
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: '4.2.0'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '4.2.0'
implementation group: 'pl.touk', name : 'throwing-function', version: '1.3'
implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.9.0'
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.7.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: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.3.0'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: '6.1.7'
implementation group: 'com.github.hmcts', name: 'ccd-case-document-am-client', version: '1.59'
implementation group: 'com.github.hmcts', name: 'core-case-data-store-client', version: '5.0.3'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: versions.fasterXmlJackson
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-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-web', version: versions.springSecurity
implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: '13.5'
implementation group: 'uk.gov.service.notify', name: 'notifications-java-client', version: '5.2.1-RELEASE'
implementation group: 'org.apache.groovy', name: 'groovy', version: '4.0.24'
annotationProcessor group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', withoutStuff
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.36'
aatAnnotationProcessor group:'org.projectlombok', name: 'lombok', version: '1.18.36'
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.6', classifier: 'all', {
exclude group: 'commons-io', module: 'commons-io'
exclude group: 'org.apache.commons', module: 'commons-lang3'
}
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.mockito', name: 'mockito-core', version: versions.mockito
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: versions.mockito
testImplementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: versions.serenity, 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.serenity
testRuntimeOnly group: 'org.junit.vintage', name :'junit-vintage-engine', version: versions.jupiter
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.jupiter
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.jupiter
aatImplementation group: 'org.apache.poi', name: 'poi', version: versions.poi
aatImplementation group: 'org.apache.poi', name: 'poi-ooxml', version: versions.poi
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: 'au.com.dius.pact.consumer', name: 'junit5', 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: 'spring', version: versions.pact_version
contractTestImplementation group: 'au.com.dius.pact.provider', name: 'junit5spring', version: versions.pact_version
contractTestImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
contractTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: versions.jupiter
contractTestImplementation sourceSets.main.runtimeClasspath
contractTestImplementation sourceSets.test.runtimeClasspath
aatImplementation 'com.github.hmcts:em-test-helper:2.0.9'
}
dependencyManagement {
dependencies {
//CVE-2022-23437
dependencySet(group: 'xerces', version: '2.12.2') {
entry 'xercesImpl'
}
//CVE-2022-1471
dependencySet(group: 'org.yaml', version: '2.3') {
entry 'snakeyaml'
}
// CVE-2023-6378
dependencySet(group: 'ch.qos.logback', version: '1.5.13') {
entry 'logback-classic'
entry 'logback-core'
}
// CVE-2023-35116
dependencySet(group: 'com.fasterxml.jackson.core', version: versions.fasterXmlJackson) {
entry 'jackson-databind'
entry 'jackson-annotations'
entry 'jackson-core'
}
dependencySet(group: 'org.junit.platform', version: '1.11.4') {
entry 'junit-platform-commons'
}
}
}
checkstyle {
// ignoreFailures = true
toolVersion = '10.21.0'
// 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)
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')
}
}
}
}
dependencyCheck {
suppressionFile = 'config/owasp/dependency-check-suppressions.xml'
}
bootJar {
getArchiveFileName().set(provider {
'rpa-em-ccd-orchestrator.jar'
})
destinationDirectory = file("$rootDir/build/libs")
manifest {
attributes 'Implementation-Title': project.name, 'Implementation-Version': project.version
}
}
def coverageExclusionList = [
'**uk/gov/hmcts/reform/em/orchestrator/Application*',
'**uk/gov/hmcts/reform/em/orchestrator/CliApplication*',
'**uk/gov/hmcts/reform/em/orchestrator/config/**/*',
'**uk/gov/hmcts/reform/em/orchestrator/domain/*',
'**uk/gov/hmcts/reform/em/orchestrator/stitching/dto/*',
'**uk/gov/hmcts/reform/em/orchestrator/info/*',
'**uk/gov/hmcts/reform/em/orchestrator/service/dto/*',
'**uk/gov/hmcts/reform/em/orchestrator/service/ccdcallbackhandler/CdamDetailsDto*',
'**uk/gov/hmcts/reform/em/orchestrator/service/ccdcallbackhandler/CcdCallbackResponseDto*',
]
jacocoTestReport {
executionData(test)
reports {
xml.required = true
csv.required = false
xml.outputLocation = file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
pitest {
targetClasses = ['uk.gov.hmcts.reform.em.orchestrator.*']
excludedClasses = [
'uk.gov.hmcts.reform.em.orchestrator.domain.*' ,
'uk.gov.hmcts.reform.em.orchestrator.config.*',
'uk.gov.hmcts.reform.em.orchestrator.info.*',
'uk.gov.hmcts.reform.em.orchestrator.Application.java',
'uk.gov.hmcts.reform.em.orchestrator.CliApplication.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"
project.tasks['sonarqube'].dependsOn test, jacocoTestReport
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"
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/orchestrator/**"
}
}
configurations {
contractTestImplementation.extendsFrom testImplementation
contractTestRuntimeOnly.extendsFrom testRuntimeOnly
}
idea {
module {
testSourceDirs += project.sourceSets.aat.java.srcDirs
testResourceDirs += project.sourceSets.aat.resources.srcDirs
testSourceDirs += project.sourceSets.contractTest.java.srcDirs
testResourceDirs += project.sourceSets.contractTest.resources.srcDirs
}
}
// 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/orchestrator/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/orchestrator/smoke/**"
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
task validateYaml(type: JavaExec){
description = "Validate the automated bundling YAML configuration"
mainClass.set("uk.gov.hmcts.reform.em.orchestrator.CliApplication")
classpath = sourceSets.main.runtimeClasspath
args '--validate'
}
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/orchestrator/**"
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
}
runAndPublishConsumerPactTests.finalizedBy pactPublish
task runProviderPactVerification(type: Test) {
logger.lifecycle("Runnning contract Tests")
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
runProviderPactVerification.dependsOn contract
runProviderPactVerification.finalizedBy pactVerify
task fortifyScan(type: JavaExec) {
mainClass.set("uk.gov.hmcts.fortifyclient.FortifyClientMainApp")
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
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
}
}
pactPublish {
pactPublish = project.pact.publish
}
task loadEnvSecrets() {
doLast {
if (!project.file('./.aat-env').exists()) {
new ByteArrayOutputStream().withStream { os ->
exec {
commandLine 'az', 'keyvault', 'secret', 'show', '--vault-name', 'em-ccdorc-aat', '-o', 'tsv', '--query', 'value', '--name', 'em-ccdorc-dot-env'
standardOutput = os
}
project.file('./.aat-env').write(new String(os.toString().replace('\n', '').decodeBase64(), java.nio.charset.StandardCharsets.UTF_8))
}
}
}
}
bootRun {
dependsOn(loadEnvSecrets)
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
}
}
}
}