generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
405 lines (342 loc) · 14.6 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
plugins {
id 'application'
id 'checkstyle'
id 'pmd'
id 'jacoco'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.owasp.dependencycheck' version '10.0.4'
id 'org.springframework.boot' version '3.3.5'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonarqube' version '5.1.0.4882'
id "org.flywaydb.flyway" version '9.22.3'
id 'info.solidsoft.pitest' version '1.15.0'
id 'uk.gov.hmcts.java' version '0.12.63'
}
group = 'uk.gov.hmcts.reform.rd'
version = '0.0.1'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
compileJava {
options.compilerArgs << '-parameters' << '-Xlint:deprecation' << "-Xlint:unchecked" << "-Werror"
}
def versions = [
junit : '5.11.3',
junitPlatform : '1.11.3',
reformLogging : '6.1.7',
springBoot : '3.3.4',
springfoxSwagger : '2.10.5',
lombok : '1.18.36',
flyway : '9.22.3',
camel : '4.8.1',
gradlePitest : '1.15.0',
pitest : '1.17.0',
sonarPitest : '0.5',
junitPitest : '1.2.1',
jackson : '2.18.1',
log4j : '2.24.2',
springVersion : '5.3.39',
logback : '1.5.12',
bouncycastle : '1.79',
restAssured : '5.5.0',
serenity : '4.2.9'
]
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
runtimeClasspath += main.output
srcDir file('src/integrationTest/java')
}
resources.srcDir file('src/integrationTest/resources')
}
smokeTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/smokeTest/java')
}
resources.srcDir file('src/smokeTest/resources')
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror"
}
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
test {
failFast = true
}
task functional(type: Test) {
description = "Runs functional tests"
group = "Verification"
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}
task smoke(type: Test) {
description = "Runs Smoke Tests"
testClassesDirs = sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
}
task integration(type: Test) {
description = "Runs integration tests"
group = "Verification"
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
failFast = true
}
task migratePostgresDatabase(type: org.flywaydb.gradle.task.FlywayMigrateTask) {
baselineOnMigrate = true
if (project.hasProperty("dburl")) {
url = "jdbc:postgresql://${dburl}"
}
}
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']
// This is a temporary fix to prevent the nightly build from failing if the Fortify scan detects issues
ignoreExitValue = true
}
checkstyle {
maxWarnings = 0
toolVersion = '8.29'
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
pmd {
toolVersion = "6.55.0"
sourceSets = [sourceSets.main, sourceSets.test, sourceSets.functionalTest, sourceSets.integrationTest, sourceSets.smokeTest]
reportsDir = file("$project.buildDir/reports/pmd")
ignoreFailures = true
ruleSets = [
'category/java/errorprone.xml',
'category/java/bestpractices.xml'
]
}
jacoco {
toolVersion = "0.8.12"
}
jacocoTestReport {
executionData(test)
reports {
xml.required = true
csv.required = false
xml.outputLocation = file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
pitest {
junit5PluginVersion = versions.junitPitest
targetClasses = ['uk.gov.hmcts.reform.locationrefdata.*']
testSourceSets = [sourceSets.test, sourceSets.functionalTest]
excludedClasses = [
'uk.gov.hmcts.reform.locationrefdata.configuration.*',
'uk.gov.hmcts.reform.locationrefdata.LrdLoadApplication',
'uk.gov.hmcts.reform.locationrefdata.constants.*',
'uk.gov.hmcts.reform.locationrefdata.camel.util.LrdExecutor',
'uk.gov.hmcts.reform.locationrefdata.camel.util.LogDto',
'uk.gov.hmcts.reform.locationrefdata.camel.binder.*'
]
excludedTestClasses = [
'uk.gov.hmcts.reform.locationrefdata.cameltest.*'
]
threads = 6
enableDefaultIncrementalAnalysis = true
historyInputLocation = 'build/reports/pitest/fastermutationtesting'
historyOutputLocation = 'build/reports/pitest/fastermutationtestingoutput'
outputFormats = ['XML', 'HTML']
timestampedReports = false
useClasspathFile = true
mutationThreshold = 75
}
project.tasks['sonarqube'].dependsOn test, jacocoTestReport
sonarqube {
properties {
property "sonar.projectName", "rd-location-ref-data-load"
property "sonar.projectKey", "uk.gov.hmcts.reform:rd-location-ref-data-load"
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.outputLocation}"
property "sonar.exclusions", "src/main/java/uk/gov/hmcts/reform/locationrefdata/configuration/**," +
"src/main/java/uk/gov/hmcts/reform/locationrefdata/LrdLoadApplication.java," +
"src/main/java/uk/gov/hmcts/reform/locationrefdata/camel/binder/**"
}
}
// 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 0-10 fails the build, anything greater and it doesn't fail the build
failBuildOnCVSS = System.getProperty('dependencyCheck.failBuild') == 'true' ? 0 : 11
suppressionFile = 'config/owasp/suppressions.xml'
analyzers {
// Disable scanning of .NET related binaries
assemblyEnabled = false
}
}
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
ext {
springCloudVersion = '2023.0.4'
}
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}"
]
]
dependencies {
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 "com.github.hmcts.java-logging:logging:${versions.reformLogging}"
implementation "com.github.hmcts.java-logging:logging-appinsights:${versions.reformLogging}"
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-batch'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
implementation group: 'jakarta.el', name: 'jakarta.el-api', version: '6.0.1'
implementation group: 'org.flywaydb', name: 'flyway-core', version: versions.flyway
implementation group: 'org.springframework.security', name: 'spring-security-core'
implementation group: 'org.springframework.security', name: 'spring-security-config'
implementation group: 'org.bouncycastle', name: 'bcpkix-jdk18on', version: versions.bouncycastle
implementation group: 'org.hibernate.validator', name: 'hibernate-validator', version: '8.0.1.Final'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: versions.log4j
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: versions.log4j
implementation group: 'org.apache.logging.log4j', name: 'log4j', version: versions.log4j
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: versions.log4j
implementation group: 'org.postgresql', name: 'postgresql', version: '42.7.4'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: versions.jackson
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: versions.jackson
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: versions.jackson
implementation group: 'com.fasterxml.jackson', name: 'jackson-bom', version: '2.18.1', ext: 'pom'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jackson
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.3'
implementation ('com.github.hmcts:data-ingestion-lib:0.6.0.0') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-web'
exclude group: 'org.glassfish', module: 'jakarta.el'
}
//Fix for CVE-2021-29425
implementation 'commons-io:commons-io:2.18.0'
implementation group: 'org.apache.camel.springboot', name: 'camel-spring-boot-starter'
implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.4.1'
implementation group: 'ch.qos.logback', name: 'logback-core', version: versions.logback
implementation group: 'ch.qos.logback', name: 'logback-classic', version: versions.logback
implementation group: 'org.springframework.cloud', name: 'spring-cloud-config-server', version: '4.1.4'
implementation group: 'io.github.openfeign', name: 'feign-jackson', version: '13.5'
compileOnly group: 'org.projectlombok', name: 'lombok', version: versions.lombok
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testImplementation libraries.junit5
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: 'io.rest-assured', name: 'rest-assured', version: '5.5.0'
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.9'
testImplementation (group: 'net.serenity-bdd', name: 'serenity-core', 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: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation 'org.codehaus.sonar-plugins:sonar-pitest-plugin:0.5', {
exclude group: 'junit', module: 'junit'
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.15.0'
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
functionalTestImplementation sourceSets.main.runtimeClasspath
functionalTestImplementation sourceSets.test.runtimeClasspath
smokeTestImplementation sourceSets.test.runtimeClasspath
testImplementation group: 'org.apache.camel', name: 'camel-test-spring-junit5', version: versions.camel
testImplementation group: 'org.apache.camel', name: 'camel-test-junit5', version: versions.camel
testImplementation group: 'org.testcontainers', name: 'postgresql', version: '1.20.4'
testImplementation group: 'org.springframework.batch', name: 'spring-batch-test'
testImplementation group: 'org.javatuples', name: 'javatuples', version: '1.2'
testImplementation group: 'org.postgresql', name: 'postgresql', version: '42.7.4'
testImplementation 'com.github.hmcts:fortify-client:1.4.5:all'
smokeTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit
functionalTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit
functionalTestRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junit
functionalTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: versions.junit
functionalTestImplementation group: 'org.junit.platform', name: 'junit-platform-commons', version: versions.junitPlatform
functionalTestRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-engine', version: versions.junitPlatform
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
application {
mainClass = 'uk.gov.hmcts.reform.locationrefdata.LrdLoadApplication'
}
bootJar {
getArchiveFileName().set(provider {
'rd-location-ref-data-load.jar'
})
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
// Fix for CVE-2021-21295 & need to be removed with new Azure blob version
configurations.all {
resolutionStrategy.eachDependency { details ->
// Fix for CVE-2020-21913 & needs to be removed when camel-azure-starter is upgraded to latest version in data-ingestion-library
if (details.requested.group == 'com.ibm.icu') {
details.useVersion "66.1"
}
}
exclude group: 'org.codehaus.jettison', module: 'jettison'
}
test {
useJUnitPlatform()
}
functional {
useJUnitPlatform()
}
rootProject.tasks.named("processSmokeTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processFunctionalTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processIntegrationTestResources") {
duplicatesStrategy = 'include'
}