-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
495 lines (411 loc) · 19.3 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:4.1.3")
classpath("au.com.dius.pact:au.com.dius.pact.gradle.plugin:4.4.0-beta.1")
}
}
plugins {
id 'application'
id 'checkstyle'
id 'jacoco'
id 'pmd'
id 'com.github.ben-manes.versions' version '0.50.0'
id 'info.solidsoft.pitest' version '1.9.11'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.owasp.dependencycheck' version '10.0.3'
id 'org.sonarqube' version '4.3.0.3225'
id 'org.springframework.boot' version '2.7.18'
id 'uk.gov.hmcts.java' version '0.12.63'
id 'io.freefair.lombok' version '6.2.0'
id 'au.com.dius.pact' version '4.2.14'
id "name.remal.randomize-test-classes" version "1.5.0"
id 'org.gradle.test-retry' version '1.5.8'
}
apply plugin: 'java'
apply plugin: "net.serenity-bdd.serenity-gradle-plugin"
apply plugin: 'project-report'
apply plugin: 'idea'
def versions = [
jupiter : '5.8.2',
junitPlatform : '1.10.1',
gradlePitest : '1.15.0',
pact_version : '4.1.38',
pitest : '1.15.3',
reformLogging : '6.0.1',
reformHealthStarter: '0.0.5',
restAssured : '5.4.0',
serenity : '4.1.3',
sonarPitest : '0.5',
springHystrix : '2.2.10.RELEASE',
springDoc : '1.7.0',
springCloud : '3.1.7'
]
ext.libraries = [
junit5: [
"org.junit.jupiter:junit-jupiter-api:${versions.junit}",
"org.junit.jupiter:junit-jupiter-engine:${versions.junit}",
"org.junit.jupiter:junit-jupiter-params:${versions.junit}",
"org.junit.platform:junit-platform-commons:${versions.junitPlatform}",
"org.junit.platform:junit-platform-engine:${versions.junitPlatform}"
]
]
mainClassName = 'uk.gov.hmcts.reform.iacasenotificationsapi.Application'
def jarName = 'ia-case-notifications-api.jar'
group = 'uk.gov.hmcts.reform'
version = '0.0.1'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
compileJava {
options.compilerArgs << '-parameters' << '-Xlint:deprecation' << "-Xlint:unchecked" << "-Werror"
}
compileTestJava {
options.compilerArgs << '-Xlint:deprecation' << "-Xlint:unchecked" << "-Werror"
}
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integrationTest/java')
}
resources.srcDir file('src/integrationTest/resources')
}
functionalTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/functionalTest/java')
}
resources.srcDir file('src/functionalTest/resources')
}
smokeTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/smokeTest/java')
}
resources.srcDir file('src/smokeTest/resources')
}
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/contractTest/java')
}
resources.srcDir file('src/contractTest/resources')
}
}
processFunctionalTestResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
processIntegrationTestResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
idea {
module {
testSourceDirs += project.sourceSets.integrationTest.java.srcDirs
testResourceDirs += project.sourceSets.integrationTest.resources.srcDirs
testSourceDirs += project.sourceSets.functionalTest.java.srcDirs
testResourceDirs += project.sourceSets.functionalTest.resources.srcDirs
testSourceDirs += project.sourceSets.smokeTest.java.srcDirs
testResourceDirs += project.sourceSets.smokeTest.resources.srcDirs
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntime.extendsFrom testRuntime
functionalTestImplementation.extendsFrom testImplementation
functionalTestRuntime.extendsFrom testRuntime
}
checkstyle {
maxWarnings = 0
toolVersion = '10.12.5'
setConfigFile(new File(rootDir, 'config/checkstyle/checkstyle.xml'))
}
pmd {
toolVersion = '6.55.0'
ignoreFailures = true
sourceSets = [sourceSets.main, sourceSets.test, sourceSets.integrationTest, sourceSets.functionalTest, sourceSets.smokeTest]
reportsDir = file("$project.buildDir/reports/pmd")
ruleSets = [
'category/java/errorprone.xml',
'category/java/bestpractices.xml'
]
}
task integration(type: Test, description: 'Runs the integration tests.', group: 'Verification') {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}
task functional(type: Test, description: 'Runs the functional tests.', group: 'Verification') {
systemProperty "scenario", System.getProperty('scenario')
systemProperty "file.encoding", "UTF-8"
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
finalizedBy aggregate
testLogging {
outputs.upToDateWhen {false}
showStandardStreams = true
showStackTraces = true
}
}
task smoke(type: Test, description: 'Runs the smoke tests.', group: 'Verification') {
testClassesDirs = sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
}
task fortifyScan(type: JavaExec, description: 'Run fortify scan.') {
mainClass = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
jacoco {
toolVersion = "0.8.11"
}
jacocoTestReport {
executionData(test, integration)
reports {
xml.required.set(true)
csv.required.set(false)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml"))
}
}
pitest {
// print('./gradlew --version'.execute().text.trim())
junit5PluginVersion = '1.1.2'
targetClasses = ['uk.gov.hmcts.reform.iacasenotificationsapi.*']
excludedClasses = [
'uk.gov.hmcts.reform.iacasenotificationsapi.infrastructure.config.*',
'uk.gov.hmcts.reform.iacasenotificationsapi.Application',
'uk.gov.hmcts.reform.iacasenotificationsapi.CcdScenarioRunnerTest'
]
threads = 10
outputFormats = ['XML', 'HTML']
timestampedReports = false
failWhenNoMutations = false
verbose = true
mutationThreshold = 85
}
project.tasks['pitest'].group = "Verification"
project.ext {
pacticipant = 'ia_caseNotificationsApi'
pacticipantVersion = System.env.GIT_COMMIT != null ? System.env.GIT_COMMIT.substring(0,9) : ''
}
task runContractTests(type: Test, description: 'Runs contract tests.', group: 'Verification') {
onlyIf {
return System.env.SKIP_CONTRACT_TESTS == null || System.env.SKIP_CONTRACT_TESTS == 'false'
}
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
systemProperty 'pact.rootDir', "pacts"
testLogging.showStandardStreams = true
}
task runAndPublishConsumerPactTests(type: Test, description: 'Publish pact test to broker.', group: 'Verification') {
logger.lifecycle("Runs pact consumer Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
runAndPublishConsumerPactTests.finalizedBy pactPublish
pact {
broker {
pactBrokerUrl = System.getenv("PACT_BROKER_FULL_URL") ?: 'http://localhost:80'
}
publish {
pactDirectory = 'pacts'
tags = [System.getenv("PACT_BRANCH_NAME") ?: 'Dev']
version = project.pacticipantVersion
}
}
sonarqube {
properties {
property "sonar.projectName", "IA :: Immigration & Asylum case notifications api"
property "sonar.projectKey", "IACASENOTIFICATIONSAPI"
property "sonar.coverage.jacoco.xmlReportPaths", layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml").get().asFile
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
property "sonar.exclusions", "src/main/java/uk/gov/hmcts/reform/iacasenotificationsapi/infrastructure/config/**," +
"src/main/java/uk/gov/hmcts/reform/iacasenotificationsapi/infrastructure/SystemDateProvider.java," +
"src/main/java/uk/gov/hmcts/reform/iacasenotificationsapi/Application.java"
property "sonar.cpd.exclusions", "src/main/java/uk/gov/hmcts/reform/iacasenotificationsapi/domain/entities/AsylumCase.java," +
"src/main/java/uk/gov/hmcts/reform/iacasenotificationsapi/domain/entities/AsylumCaseBuilder.java," +
"src/main/java/uk/gov/hmcts/reform/iacasenotificationsapi/domain/personalisation/**"
}
}
project.tasks['sonarqube'].dependsOn test, integration, jacocoTestReport
project.tasks['sonarqube'].group = "Verification"
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://www.jitpack.io'
}
}
dependencyManagement {
dependencies {
dependencySet(group: 'org.yaml', version: '2.2') {
entry 'snakeyaml'
}
dependencySet(group: 'commons-fileupload', version: '1.5') {
entry 'commons-fileupload'
}
dependencySet(group: 'com.fasterxml.jackson.core', version: '2.16.0') {
entry 'jackson-databind'
entry 'jackson-core'
entry 'jackson-annotations'
}
dependencySet(group: 'com.fasterxml.jackson.dataformat', version: '2.16.0') {
entry 'jackson-dataformat-yaml'
entry 'jackson-dataformat-csv'
}
dependencySet(group: 'com.fasterxml.jackson.datatype', version: '2.16.0') {
entry 'jackson-datatype-jsr310'
entry 'jackson-datatype-jdk8'
}
}
}
dependencies {
modules {
module("org.codehaus.groovy:groovy") {
replacedBy("org.apache.groovy:groovy", "conflicts in current rest-assured version")
}
module("org.codehaus.groovy:groovy-xml") {
replacedBy("org.apache.groovy:groovy-xml", "conflicts in current rest-assured version")
}
module("org.codehaus.groovy:groovy-json") {
replacedBy("org.apache.groovy:groovy-json", "conflicts in current rest-assured version")
}
}
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-json'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation'
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-client'
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-resource-server'
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-jose'
// CVE-2019-17195
implementation group: 'com.nimbusds', name: 'nimbus-jose-jwt', version: '9.37.2'
// CVE-2021-27568
implementation group: 'net.minidev', name: 'json-smart', version: '2.5.0'
implementation group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '2.9.3'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-csv'
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: versions.springDoc
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.13'
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.13'
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.0'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.83'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: '9.0.83'
implementation group: 'com.sun.xml.bind', name: 'jaxb-osgi', version: '2.3.9'
implementation (group: 'com.github.hmcts', name: 'document-management-client', version: '7.0.1'){
exclude group: "org.bouncycastle", module: "bcprov-jdk15on"
}
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.reformLogging
implementation group: 'com.github.hmcts.java-logging', name: 'logging-appinsights', version: versions.reformLogging
implementation(group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '4.0.2') {
exclude group: "org.bouncycastle", module: "bcprov-jdk15on"
}
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.15.1'
implementation(group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '3.1.8') {
exclude group: "org.bouncycastle", module: "bcprov-jdk15on"
}
implementation(group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap' , version: '3.1.7') {
exclude group: "org.bouncycastle", module: "bcprov-jdk15on"
}
implementation group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: '1.75'
implementation 'ch.qos.logback:logback-classic:1.2.13'
implementation 'ch.qos.logback:logback-core:1.2.13'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-cache'
implementation group: 'uk.gov.service.notify', name: 'notifications-java-client', version: '5.0.1-RELEASE'
implementation group: 'com.google.guava', name: 'guava', version: '32.1.3-jre'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
compileOnly 'org.projectlombok:lombok:1.18.30'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
implementation group: 'com.launchdarkly', name: 'launchdarkly-java-server-sdk', version: '6.2.1'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '3.6.28'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.16.1'
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.9'
testImplementation(group: 'org.springframework.boot', name: 'spring-boot-starter-test') {
exclude group: "com.vaadin.external.google", module: "android-json"
}
testImplementation group: 'org.pitest', name: 'pitest', version: versions.pitest
testImplementation "info.solidsoft.gradle.pitest:gradle-pitest-plugin:${versions.gradlePitest}"
testImplementation "org.codehaus.sonar-plugins:sonar-pitest-plugin:${versions.sonarPitest}"
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation group: 'org.springframework.security', name: 'spring-security-test'
testImplementation(group: 'io.rest-assured', name: 'rest-assured-all', version: versions.restAssured)
testImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
testImplementation group: 'net.serenity-bdd', name: 'serenity-core', version: versions.serenity
testImplementation group: 'net.serenity-bdd', name: 'serenity-junit', version: versions.serenity
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: 'com.github.hmcts', name: 'fortify-client', version: '1.3.0', classifier: 'all', {
exclude group: 'commons-io', module: 'commons-io'
exclude group: 'org.apache.commons', module: 'commons-lang3'
}
testImplementation 'pl.pragmatists:JUnitParams:1.1.1'
testImplementation(group: 'org.springframework.cloud', name: 'spring-cloud-contract-wiremock', version: '3.1.6') {
exclude group: "com.github.tomakehurst", module: "wiremock-standalone"
}
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
functionalTestImplementation sourceSets.main.runtimeClasspath
functionalTestImplementation sourceSets.test.runtimeClasspath
smokeTestImplementation sourceSets.main.runtimeClasspath
smokeTestImplementation sourceSets.test.runtimeClasspath
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-api', version: versions.junit
contractTestRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version : versions.junit
contractTestImplementation sourceSets.main.runtimeClasspath
contractTestImplementation sourceSets.test.runtimeClasspath
}
dependencyCheck {
suppressionFile = 'config/owasp/suppressions.xml'
}
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')
}
}
}
}
gradle.startParameter.continueOnFailure = true
bootJar {
getArchiveFileName().set(jarName)
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
// this is required to force Java running on the Azure Windows Server OS into using
// UTF-8 as the default character set instead of windows-1252 which causes issues.
// this setting only applies when running via gradle bootRun -- see web.config for the
// java flag that configures the deployed appllications
applicationDefaultJvmArgs = ["-Dfile.encoding=UTF-8", "-Dhttps.protocols=TLSv1.2"]
wrapper {
distributionType = Wrapper.DistributionType.ALL
}