-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
402 lines (357 loc) · 19 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
plugins {
id 'application'
id 'java'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.springframework.boot' version '3.3.5'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'com.gorylenko.gradle-git-properties' version '2.4.2'
id 'info.solidsoft.pitest' version '1.15.0'
id 'au.com.dius.pact' version '4.6.16'
id 'net.serenity-bdd.serenity-gradle-plugin' version '4.2.8'
id 'org.sonarqube' version '6.0.1.5171'
id 'uk.gov.hmcts.java' version '0.12.63'
id 'project-report'
id 'jacoco'
}
application {
mainClass = 'uk.gov.hmcts.probate.OrchestratorApplication'
group = 'uk.gov.hmcts.probate'
version = "4.0.0"
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
project.ext {
pactVersion = getCheckedOutGitCommitHash()
}
jacoco {
toolVersion = '0.8.12'
}
sonar {
properties {
property "sonar.exclusions", "**uk/gov/hmcts/probate/appinsights/*, **/PaMapper.java, **/IntestacyMapper.java, " +
"**/ScheduledConfiguration.java, **/AuthenticateUserResponse.java, **/TokenExchangeResponse.java, " +
"**/FormDataMigrator.java, **/IdamUserEmail.java, **/IdamUsersCsvLoader.java, " +
"**uk/gov/hmcts/probate/OrchestratorApplication.java"
property "sonar.projectName", "PROBATE :: Probate-Orchestrator-Service"
property "sonar.projectKey", "Probate-Orchestrator-Service"
property "sonar.coverage.jacoco.xmlReportPaths", "${layout.buildDirectory.get()}/jacoco/test/html/jacocoTestReport.xml"
property "sonar.host.url", "https://sonar.reform.hmcts.net/"
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
}
}
test.finalizedBy jacocoTestReport
dependencyCheck {
suppressionFile = 'config/owasp/suppressions.xml'
}
pitest {
targetClasses = ['uk.gov.hmcts.probate.*']
threads = 10
outputFormats = ['XML', 'HTML']
timestampedReports = false
mutationThreshold = 50
timeoutConstInMillis = 30000
}
sourceSets {
testSmoke {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/smokeTest/java')
}
resources.srcDir file('src/smokeTest/resources')
}
testFunctional {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/functionalTest/java')
}
resources.srcDir file('src/functionalTest/resources')
}
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/contractTest/java')
}
resources.srcDir file('src/contractTest/resources')
}
testIntegration {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/integrationTest/java')
}
resources.srcDir file('src/integrationTest/resources')
}
}
processContractTestResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
processContractTestResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
task integration(type: Test) {
description = "Runs integration tests"
testClassesDirs = sourceSets.testIntegration.output.classesDirs
classpath = sourceSets.testIntegration.runtimeClasspath
}
task smoke(type: Test) {
description = "Runs Smoke Tests"
testClassesDirs = sourceSets.testSmoke.output.classesDirs
classpath = sourceSets.testSmoke.runtimeClasspath
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
task functional(type: Test) {
description = "Runs functional Tests"
testClassesDirs = sourceSets.testFunctional.output.classesDirs
classpath = sourceSets.testFunctional.runtimeClasspath
finalizedBy aggregate
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
functional.finalizedBy(aggregate)
task runProviderPactVerification(type: Test) {
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
if (project.hasProperty('pact.verifier.publishResults')) {
systemProperty 'pact.verifier.publishResults', project.property('pact.verifier.publishResults')
}
systemProperty 'pact.provider.version', project.pactVersion
}
task runProviderPactTests(type: Test) {
description = "Runs Provider Contract Tests"
println 'runProviderPactTests-PACT_BROKER_FULL_URL=' + System.getenv("PACT_BROKER_FULL_URL")
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
task runConsumerPactTests(type: Test) {
description = "Runs Contract Tests"
println 'runProviderPactTests-PACT_BROKER_FULL_URL=' + System.getenv("PACT_BROKER_FULL_URL")
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
tasks.withType(Test) {
maxHeapSize = "1024m"
useJUnitPlatform()
}
def versions = [
authCheckerLib : '3.0.1',
commonsIO : '2.18.0',
commonMark : '0.17.0',
feign : '13.5',
hmctsJavaLogging : '6.1.7',
jacksonDatabind : '2.18.2',
junitJupiter : '5.10.2',
lombok : '1.18.36',
mapStruct : '1.3.0.Final',
pact_version : '4.1.34',
piTest : '1.17.3',
probateCommonsVersion : '2.0.31',
restAssured : '5.5.0',
serenity : '4.2.9',
serviceAuthProviderClient : '5.3.0',
serviceTokenGenerator : '0.6.0',
springBootVersion : '3.3.5',
springCloudWiremock : '4.2.0',
springDocOpenUi : '2.6.0',
springSecurityVersion : '6.4.2'
]
jacocoTestReport {
executionData(test, integration)
reports {
xml.required = true
csv.required = false
xml.outputLocation = file("${layout.buildDirectory.get()}/reports/jacoco/test/jacocoTestReport.xml")
}
}
check.dependsOn(integration)
repositories {
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2023.0.4"
}
}
configurations {
smokeTestImplementation.extendsFrom testImplementation
smokeTestRuntimeOnly.extendsFrom runtimeOnly
}
ext['snakeyaml.version'] = '2.0'
dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: versions.springBootVersion
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: versions.springBootVersion
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: versions.springBootVersion
implementation group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', version: versions.springBootVersion
implementation group: 'org.springframework.security', name: 'spring-security-core', version: versions.springSecurityVersion
implementation group: 'org.springframework.cloud', name: 'spring-cloud-openfeign-core'
implementation group: 'org.springframework.retry', name: 'spring-retry', version: '2.0.11'
implementation group: 'com.google.guava', name: 'guava', version: '33.4.0-jre'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jacksonDatabind
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: versions.jacksonDatabind
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: versions.jacksonDatabind
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-hateoas', version: versions.springBootVersion
implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: versions.feign
implementation group: 'io.github.openfeign', name: 'feign-jackson', version: versions.feign
implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.3.1'
implementation group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '3.1.8'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.hmctsJavaLogging
implementation group: 'com.github.hmcts.java-logging', name: 'logging-appinsights', version: versions.hmctsJavaLogging
implementation group: 'com.github.hmcts', name: 'auth-checker-lib', version: versions.authCheckerLib
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: versions.serviceAuthProviderClient
implementation group: 'com.github.hmcts', name: 'probate-commons', version: versions.probateCommonsVersion
implementation group: 'com.microsoft.azure', name: 'applicationinsights-spring-boot-starter', version: '2.6.4'
implementation group: 'commons-io', name: 'commons-io', version: versions.commonsIO
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: versions.springDocOpenUi
implementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
implementation group: 'org.mapstruct', name: 'mapstruct', version: '1.5.5.Final'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-csv', version: versions.jacksonDatabind
implementation group: 'org.pitest', name: 'pitest', version: versions.piTest
implementation group: 'com.atlassian.commonmark', name: 'commonmark', version: versions.commonMark
implementation group: 'info.solidsoft.gradle.pitest', name: 'gradle-pitest-plugin', version: '1.15.0'
implementation group: 'org.sonarsource.api.plugin', name: 'sonar-plugin-api', version: '11.0.0.2664'
implementation group: 'org.mapstruct', name: 'mapstruct-processor', version: versions.mapStruct
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jacksonDatabind
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.0'
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
annotationProcessor group: 'org.mapstruct', name: 'mapstruct-processor', version: versions.mapStruct
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation group: 'org.springframework.security', name: 'spring-security-test', version: versions.springSecurityVersion
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-hateoas', version: versions.springBootVersion
testImplementation group: 'org.springframework.cloud', name: 'spring-cloud-contract-wiremock', version: versions.springCloudWiremock
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
testImplementation group: 'org.mapstruct', name: 'mapstruct-jdk8', version: versions.mapStruct
testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jacksonDatabind
testImplementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-csv', version: versions.jacksonDatabind
testImplementation group: 'io.github.openfeign', name: 'feign-core', version: versions.feign
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.6', classifier: 'all'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junitJupiter
testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testAnnotationProcessor group: 'org.mapstruct', name: 'mapstruct-processor', version: versions.mapStruct
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junitJupiter
testIntegrationImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testIntegrationImplementation group: 'org.springframework.security', name: 'spring-security-test', version: versions.springSecurityVersion
testIntegrationImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-hateoas', version: versions.springBootVersion
testIntegrationImplementation group: 'org.springframework.cloud', name: 'spring-cloud-contract-wiremock', version: versions.springCloudWiremock
testIntegrationImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
testIntegrationImplementation group: 'org.mapstruct', name: 'mapstruct-jdk8', version: versions.mapStruct
testIntegrationImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jacksonDatabind
testIntegrationImplementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-csv', version: versions.jacksonDatabind
testIntegrationImplementation group: 'io.github.openfeign', name: 'feign-core', version: versions.feign
testIntegrationImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.6'
testIntegrationImplementation group: 'com.github.hmcts', name: 'probate-commons', version: versions.probateCommonsVersion
testIntegrationImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junitJupiter
testIntegrationRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junitJupiter
testIntegrationImplementation sourceSets.main.runtimeClasspath
testIntegrationImplementation sourceSets.test.runtimeClasspath
testSmokeImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
testSmokeImplementation sourceSets.main.runtimeClasspath
testSmokeImplementation sourceSets.test.runtimeClasspath
testFunctionalImplementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: versions.serenity
testFunctionalImplementation group: 'net.serenity-bdd', name: 'serenity-core', version: versions.serenity
testFunctionalImplementation group: 'net.serenity-bdd', name: 'serenity-junit5', version: versions.serenity
testFunctionalImplementation group: 'net.serenity-bdd', name: 'serenity-spring', version: versions.serenity
testFunctionalImplementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.12.6'
testFunctionalImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
testFunctionalImplementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testFunctionalImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jacksonDatabind
testFunctionalAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testFunctionalImplementation sourceSets.main.runtimeClasspath
testFunctionalImplementation sourceSets.test.runtimeClasspath
contractTestImplementation group: 'io.github.openfeign', name: 'feign-core', version: versions.feign
contractTestImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: versions.pact_version
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'java8', 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.junit.jupiter', name: 'junit-jupiter-api', version: versions.junitJupiter
contractTestRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junitJupiter
contractTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junitJupiter
contractTestImplementation sourceSets.main.runtimeClasspath
contractTestImplementation sourceSets.test.runtimeClasspath
contractTestImplementation group: 'io.github.openfeign', name: 'feign-core', version: versions.feign
}
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']
}
def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}
project.ext {
pactVersion = getCheckedOutGitCommitHash()
}
task runAndPublishConsumerPactTests(type: Test){
logger.lifecycle("Runs PublishConsumer pact tests")
systemProperty 'pact.rootDir', "pacts"
println 'runAndPublishConsumerPactTests-PACT_BROKER_FULL_URL=' + System.getenv("PACT_BROKER_FULL_URL")
println 'runAndPublishConsumerPactTests-pact.rootDir=' + System.getenv("pact.rootDir")
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
pact {
println 'pact-PACT_BROKER_FULL_URL=' + System.getenv("PACT_BROKER_FULL_URL")
broker {
pactBrokerUrl = System.getenv("PACT_BROKER_FULL_URL") ?:'http://localshost:80'
}
publish {
pactDirectory = 'target/pacts'
pactBrokerUrl = System.getenv("PACT_BROKER_FULL_URL") ?: 'http://localhost:80'
tags = [System.getenv("PACT_BRANCH_NAME") ?: 'Dev']
version = project.pactVersion
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-parameters"
}
// https://github.com/gradle/gradle/issues/16791
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
bootJar {
archiveFileName = 'probate-orchestrator-service.jar'
manifest {
attributes 'Implementation-Title': project.name,
'Implementation-Version': project.version
}
}
task generateAatEnvFile() {
doFirst {
print 'Generating AAT env var file'
"sh bin/generate-aat-env-file.sh".execute()
// Sleep to allow secrets to be fetched:
sleep(20 * 1000)
}
}
run {
if (new Boolean(System.getenv("POINT_TO_AAT"))) {
print 'Exporting AAT env vars'
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
}
}
}
}
if (debug == 'true') {
jvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005']
}
}
rootProject.tasks.named("processResources") {
dependsOn("generateGitProperties")
}