forked from hmcts/sscs-hearings-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
471 lines (386 loc) · 15.9 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
plugins {
id 'application'
id 'checkstyle'
id 'pmd'
id 'jacoco'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id 'org.springframework.boot' version '2.7.1'
id 'uk.gov.hmcts.java' version '0.12.27'
id 'org.owasp.dependencycheck' version '7.2.1'
id 'com.github.ben-manes.versions' version '0.42.0'
id 'org.sonarqube' version '3.4.0.2513'
id 'info.solidsoft.pitest' version '1.7.0'
id 'com.gorylenko.gradle-git-properties' version '2.4.0'
id 'au.com.dius.pact' version '4.3.10'
}
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'info.solidsoft.pitest'
gitProperties {
gitPropertiesDir = new File("${project.rootDir}/src/main/resources/uk/gov/hmcts/reform/sscs")
keys = ['git.commit.id', 'git.commit.time']
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "GMT"
}
processResources.dependsOn(':generateGitProperties')
group = 'uk.gov.hmcts.reform'
version = '0.0.1'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
sourceSets {
functionalTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/functionalTest/java')
}
resources.srcDir file('src/functionalTest/resources')
}
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integrationTest/java')
}
resources.srcDir file('src/integrationTest/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')
}
}
task integration(type: Test) {
description = "Runs integration tests"
group = "Verification"
setTestClassesDirs(sourceSets.integrationTest.output.classesDirs)
setClasspath(sourceSets.integrationTest.runtimeClasspath)
}
task functional(type: Test) {
group = 'Verification'
description = 'Executes non-destructive functional tests in AAT against a running CCD and notification service.'
setTestClassesDirs(sourceSets.functionalTest.output.classesDirs)
setClasspath(sourceSets.functionalTest.runtimeClasspath)
}
task smoke(type: Test) {
group = 'Verification'
description = 'Executes non-destructive smoke tests against a running SSCS hearings API application.'
setTestClassesDirs(sourceSets.smokeTest.output.classesDirs)
setClasspath(sourceSets.smokeTest.runtimeClasspath)
}
task contract(type: Test) {
group = 'Verification'
description = 'Executes consumer Pact tests.'
setTestClassesDirs(sourceSets.contractTest.output.classesDirs)
setClasspath(sourceSets.contractTest.runtimeClasspath)
}
task runAndPublishConsumerPactTests(type: Test){
logger.lifecycle("Runs pact Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
runAndPublishConsumerPactTests.dependsOn contract
runAndPublishConsumerPactTests.finalizedBy pactPublish
configurations {
functionalTestImplementation.extendsFrom testImplementation
functionalTestRuntimeOnly.extendsFrom testRuntimeOnly
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
smokeTestImplementation.extendsFrom testImplementation
smokeTestRuntimeOnly.extendsFrom testRuntimeOnly
contractTestImplementation.extendsFrom testImplementation
contractTestRuntimeOnly.extendsFrom testRuntimeOnly
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror" << '-Xlint:deprecation'
}
// https://github.com/gradle/gradle/issues/16791
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
checkstyle {
maxWarnings = 0
toolVersion = '9.2.1'
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
pmd {
toolVersion = "6.42.0"
reportsDir = file("$project.buildDir/reports/pmd")
// https://github.com/pmd/pmd/issues/876
ruleSets = []
ruleSetFiles = files("config/pmd/ruleset.xml")
group = 'Verification'
}
pmdMain {
group = 'Verification'
ignoreFailures = false
}
pmdTest {
group = 'Verification'
ignoreFailures = true
}
pmdContractTest {
group = 'Verification'
ignoreFailures = true
}
pmdSmokeTest {
group = 'Verification'
ignoreFailures = true
}
pmdFunctionalTest {
group = 'Verification'
ignoreFailures = true
}
pmdIntegrationTest {
group = 'Verification'
ignoreFailures = true
}
jacocoTestReport {
executionData(test, integration)
reports {
xml.required = true
csv.required = false
xml.destination file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
project.tasks['sonarqube'].dependsOn test, integration, jacocoTestReport
check.dependsOn integration
checkstyleMain.shouldRunAfter(compileJava)
test.shouldRunAfter(checkstyleTest)
integration.shouldRunAfter(checkstyleIntegrationTest)
integration.shouldRunAfter(test)
sonarqube {
properties {
property "sonar.projectName", "SSCS - Hearings Api"
property "sonar.projectKey", "SSCSHA"
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.destination.path}"
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
property "sonar.exclusions", "src/main/java/uk/gov/hmcts/reform/sscs/HearingsApiApplication.java," +
"src/main/java/uk/gov/hmcts/reform/sscs/config/**," +
"src/main/java/uk/gov/hmcts/reform/sscs/model/**," +
"src/main/java/uk/gov/hmcts/reform/sscs/service/holder/**,"
}
}
pitest {
junit5PluginVersion = '0.15'
targetClasses = ['uk.gov.hmcts.reform.sscs.*']
excludedClasses = [
'uk.gov.hmcts.reform.sscs.config.*',
'uk.gov.hmcts.reform.sscs.HearingsApiApplication'
]
threads = 10
outputFormats = ['XML', 'HTML']
timestampedReports = false
mutationThreshold = 80
}
project.tasks['pitest'].group = "Verification"
// before committing a change, make sure task still works
dependencyUpdates {
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { qualifier -> version.toUpperCase().contains(qualifier) }
def regex = /^[0-9,.v-]+$/
return !stableKeyword && !(version ==~ regex)
}
rejectVersionIf { selection -> // <---- notice how the closure argument is named
return isNonStable(selection.candidate.version) && !isNonStable(selection.currentVersion)
}
}
// https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/configuration.html
dependencyCheck {
// Specifies if the build should be failed if a CVSS score above a specified level is identified.
// range of 7-10 fails the build, anything lower and it doesn't fail the build
failBuildOnCVSS = System.getProperty('dependencyCheck.failBuild') == 'true' ? 7.0 : 11
suppressionFile = 'config/owasp/suppressions.xml'
cveValidForHours = 24
analyzers {
// Disable scanning of .NET related binaries
assemblyEnabled = false
retirejs {
enabled = false
}
ossIndex {
enabled = false
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
// Requires authentication, if it gets here the library cannot be found!
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter'
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-aop'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-json'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-activemq'
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-resource-server', version: '5.7.5'
implementation group: 'org.springframework.security', name: 'spring-security-crypto', version: '5.7.5'
implementation group: 'org.springframework.security', name: 'spring-security-web', version: '5.7.5'
implementation group: 'org.springframework.security', name: 'spring-security-config', version: '5.7.5'
implementation group: 'org.springframework.security', name: 'spring-security-core', version: '5.7.5'
implementation group: 'org.springframework.security', name: 'spring-security-oauth2-core', version: '5.7.5'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter'
implementation group: 'org.springframework.retry', name: 'spring-retry', version: '1.3.3'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.68'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-el', version: '9.0.68'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: '9.0.68'
implementation group: 'org.apache.qpid', name: 'qpid-jms-client', version: '1.6.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: '2.17.1'
implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: '11.7'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.9.2'
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.6'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: '5.1.9'
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '4.0.3'
implementation group: 'com.github.hmcts', name: 'ccd-client', version: '4.8.6'
implementation group: 'org.projectlombok', name:'lombok', version: '1.18.22'
annotationProcessor group: 'org.projectlombok', name:'lombok', version: '1.18.22'
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.10'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.10'
implementation group: 'com.github.hmcts', name: 'sscs-common', version: '4.21.1'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.14.0-rc3'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.14.0-rc3'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.14.0-rc3'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.0-rc3'
implementation group: 'com.networknt', name: 'json-schema-validator', version: '1.0.66'
implementation group: 'com.azure', name: 'azure-core', version: '1.26.0'
implementation group: 'com.azure', name: 'azure-messaging-servicebus', version: '7.7.0'
implementation group: 'com.networknt', name: 'json-schema-validator', version: '1.0.71'
implementation group: 'org.elasticsearch', name: 'elasticsearch', version: '7.16.3'
implementation group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.6.4'
// https://mvnrepository.com/artifact/com.microsoft.azure/applicationinsights-web
implementation group: 'com.microsoft.azure', name: 'applicationinsights-web', version: '2.6.4'
testImplementation group: 'io.rest-assured', name: 'rest-assured', version: '4.5.1'
testImplementation group: 'io.rest-assured', name: 'xml-path', version: '4.5.1'
testImplementation group: 'io.rest-assured', name: 'json-path', version: '4.5.1'
testImplementation group: 'org.projectlombok', name:'lombok', version: '1.18.22'
testAnnotationProcessor group: 'org.projectlombok', name:'lombok', version: '1.18.22'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', {
exclude group: 'junit', module: 'junit'
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.2'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.2'
testImplementation group: 'org.pitest', name: 'pitest', version: '1.7.3'
testImplementation group: 'info.solidsoft.gradle.pitest', name: 'gradle-pitest-plugin', version: '1.5.2'
testImplementation group: 'org.codehaus.sonar-plugins', name: 'sonar-pitest-plugin', version: '0.5'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.22.0'
testImplementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
testImplementation group: 'com.github.tomakehurst', name: 'wiremock', version: '2.27.2'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '4.6.1'
//pact contract testing
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: '4.1.7'
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'java8', version: '4.1.7'
contractTestRuntimeOnly group: 'au.com.dius.pact.consumer', name: 'junit5', version: '4.1.7'
contractTestRuntimeOnly group: 'au.com.dius.pact.consumer', name: 'java8', version: '4.1.7'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2021.0.1"
}
dependencies {
//CVE-2016-1000027
dependencySet(group: 'org.springframework', version: '5.3.22') {
entry 'spring-aop'
entry 'spring-aspects'
entry 'spring-beans'
entry 'spring-context'
entry 'spring-context-support'
entry 'spring-core'
entry 'spring-expression'
entry 'spring-jcl'
entry 'spring-jdbc'
entry 'spring-orm'
entry 'spring-tx'
entry 'spring-web'
entry 'spring-webmvc'
entry 'spring-jms'
entry 'spring-messaging'
}
// CVE-2022-38752
dependencySet(group: 'org.yaml', version: '1.33') {
entry 'snakeyaml'
}
}
}
mainClassName = 'uk.gov.hmcts.reform.sscs.HearingsApiApplication'
bootJar {
archiveFileName = "sscs-hearings-api.jar"
manifest {
attributes('Implementation-Title': project.name, 'Implementation-Version': project.version.toString())
}
}
// Gradle 7.x issue, workaround from: https://github.com/gradle/gradle/issues/17236#issuecomment-894768083
rootProject.tasks.named("processSmokeTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processFunctionalTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processContractTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processIntegrationTestResources") {
duplicatesStrategy = 'include'
}
task fortifyScan(type: JavaExec) {
mainClass = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
project.ext {
pacticipant = 'sscs-hearings-api'
pacticipantVersion = getCheckedOutGitCommitHash()
}
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
}
}
static def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}
run {
def debug = System.getProperty("debug")
if (debug == 'true') {
jvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006']
}
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}