generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
418 lines (363 loc) · 15.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
buildscript {
dependencies {
classpath "org.flywaydb:flyway-database-postgresql:11.1.0"
}
}
plugins {
id 'application'
id 'checkstyle'
id 'uk.gov.hmcts.java' version '0.12.63'
id 'pmd'
id 'jacoco'
id 'io.spring.dependency-management' version '1.1.7'
id 'net.serenity-bdd.serenity-gradle-plugin' version '4.2.8'
id 'org.springframework.boot' version '3.4.0'
id 'org.owasp.dependencycheck' version '11.1.1'
id 'com.github.ben-manes.versions' version '0.51.0'
id "info.solidsoft.pitest" version '1.15.0'
id 'org.sonarqube' version '6.0.1.5171'
id 'com.gorylenko.gradle-git-properties' version '2.4.2'
id "io.freefair.lombok" version "8.11"
id "org.flywaydb.flyway" version "11.1.0"
}
apply plugin: "com.gorylenko.gradle-git-properties"
apply plugin: "org.owasp.dependencycheck"
group = 'uk.gov.hmcts.reform'
version = '1.0.2'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
gitProperties {
gitPropertiesDir = new File("${project.rootDir}/src/main/resources/uk/gov/hmcts/reform/pcqbackend/gitcommit")
keys = ['git.commit.id','git.commit.time']
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "GMT"
}
sourceSets {
test {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/test/java')
}
resources.srcDir file('src/test/resources')
}
functionalTest {
java {
compileClasspath += main.output
runtimeClasspath += main.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')
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntime.extendsFrom testRuntime
functionalTestImplementation.extendsFrom testImplementation
functionalTestRuntime.extendsFrom testRuntime
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror"
}
task unit(type: Test, description: 'Runs the unit tests.', group: 'Verification') {
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
useJUnitPlatform()
}
task functional(type: Test, description: 'Runs the functional tests.', group: 'Verification') {
systemProperty "scenario", System.getProperty('scenario')
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
finalizedBy aggregate
}
task integration(type: Test, description: 'Runs the integration tests.', group: 'Verification') {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
//useJUnitPlatform()
// set your environment variables here
// environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
task smoke(type: Test) {
description = "Runs Smoke Tests"
testClassesDirs = sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
}
task fortifyScan(type: JavaExec) {
mainClass = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
checkstyle {
maxWarnings = 0
toolVersion = '10.21.0'
// need to set configDir to rootDir otherwise submodule will use submodule/config/checkstyle
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
pmd {
sourceSets = [sourceSets.main, sourceSets.test, sourceSets.functionalTest, sourceSets.integrationTest, sourceSets.smokeTest]
reportsDir = file("$project.buildDir/reports/pmd")
// https://github.com/pmd/pmd/issues/876
ruleSets = []
ruleSetFiles = files("config/pmd/ruleset.xml")
}
project.tasks['jacocoTestReport'].dependsOn test, integration
jacocoTestReport {
executionData(test, integration)
reports {
xml.required = true
csv.required = false
xml.outputLocation = file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
project.tasks['sonarqube'].dependsOn jacocoTestReport
pitest {
junit5PluginVersion.set('1.2.1')
targetClasses = ['uk.gov.hmcts.reform.pcqbackend.*']
excludedClasses = [
'uk.gov.hmcts.reform.pcqbackend.utils.*'
]
threads = 10
enableDefaultIncrementalAnalysis = true
outputFormats = ['XML', 'HTML']
timestampedReports = false
mutationThreshold = 50
timeoutConstInMillis = 30000
mutators.set([
'CONDITIONALS_BOUNDARY',
'INCREMENTS',
'INVERT_NEGS',
'MATH',
'NEGATE_CONDITIONALS',
'VOID_METHOD_CALLS',
'EMPTY_RETURNS',
'FALSE_RETURNS',
'NULL_RETURNS',
'PRIMITIVE_RETURNS',
'TRUE_RETURNS',
'REMOVE_CONDITIONALS'
])
}
project.tasks['pitest'].group = "Verification"
sonarqube {
properties {
property "sonar.projectName", "Reform :: pcq-backend"
property "sonar.projectKey", "uk.gov.hmcts.reform:pcq-backend"
property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
}
}
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all {
def isNonStable = { String version ->
['alpha', 'beta', 'rc', 'cr', 'm', 'preview', 'b', 'ea'].any { qualifier ->
version ==~ /(?i).*[.-]\$qualifier[.\\d-+]*/
}
}
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
selection.reject('Release candidate')
}
}
}
}
// https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/configuration.html
dependencyCheck {
suppressionFile = 'config/owasp/suppressions.xml'
}
dependencyManagement {
dependencies {
// CVE-2021-21290
dependency group: 'com.azure', name: 'azure-core-http-netty', version: '1.15.7'
dependencySet(group: 'io.netty', version: '4.1.116.Final') {
entry 'netty-buffer'
entry 'netty-codec'
entry 'netty-codec-http'
entry 'netty-codec-http2'
entry 'netty-codec-socks'
entry 'netty-common'
entry 'netty-handler'
entry 'netty-handler-proxy'
entry 'netty-resolver'
entry 'netty-transport'
entry 'netty-transport-native-epoll'
entry 'netty-transport-native-kqueue'
entry 'netty-transport-native-unix-common'
entry 'netty-codec-dns'
entry 'netty-resolver-dns'
entry 'netty-resolver-dns-native-macos'
entry 'netty-resolver-dns-classes-macos'
entry 'netty-transport-classes-epoll'
entry 'netty-transport-classes-kqueue'
}
// CVE-2018-10237 - Unbounded memory allocation
// CVE-2020-8908 - Temp directory creation vulnerability
dependencySet(group: 'com.google.guava', version: '33.4.0-jre') {
entry 'guava'
}
// CVE-2021-29425
dependency group: 'commons-io', name: 'commons-io', version: '2.18.0'
dependencySet(group: 'org.springframework.cloud', version: '4.2.0') {
entry 'spring-cloud-starter-openfeign'
entry 'spring-cloud-openfeign-core'
}
}
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2024.0.0'
}
}
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
def versions = [
flywaydb : '11.1.0',
jjwt : '0.12.6',
junit : '5.11.4',
junitPlatform : '1.11.4',
springBoot : springBoot.class.package.implementationVersion,
restAssured : '5.5.0',
serenity : '4.2.9',
lombok : '1.18.36',
gradlePitest : '1.15.0',
sonarPitest : '0.5',
testcontainers : '1.20.4',
springCloud : '4.2.0'
]
dependencies {
implementation group: 'com.azure', name: 'azure-storage-blob', version: '12.29.0'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: '6.1.7'
implementation group: 'com.github.hmcts', name: 'pcq-commons', version: '1.2.5'
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.3.0'
implementation group: 'com.microsoft.azure', name: 'applicationinsights-web', version: '3.6.2'
implementation group: 'com.microsoft.azure', name: 'azure-storage', version: '8.6.6'
implementation group: 'commons-fileupload', name: 'commons-fileupload', version: '1.5'
implementation group: 'commons-net', name: 'commons-net', version: '3.11.1'
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: versions.jjwt
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
implementation group: 'org.flywaydb', name: 'flyway-core', version: versions.flywaydb
implementation group: 'org.flywaydb', name: 'flyway-database-postgresql', version: versions.flywaydb
implementation group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '4.0.5'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.7.4'
implementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.7.0'
implementation group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'
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-data-jpa'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc'
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-validation'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web-services'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: versions.springCloud
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: "4.2.0"
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.3'
implementation group: "com.networknt", name: "json-schema-validator", version: '1.5.4'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: versions.jjwt
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: versions.jjwt
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.6', classifier: 'all'
testImplementation group: 'com.github.tomakehurst', name: 'wiremock-jre8-standalone', version: '3.0.1'
testImplementation group: 'info.solidsoft.gradle.pitest', name: 'gradle-pitest-plugin', version: versions.gradlePitest
testImplementation group: 'io.rest-assured', name: 'json-path', version: versions.restAssured
testImplementation group: 'io.rest-assured', name: 'rest-assured-common', version: versions.restAssured
testImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
testImplementation group: 'io.rest-assured', name: 'xml-path', 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: 'org.assertj', name: 'assertj-core', version: '3.26.3'
testImplementation group: 'org.codehaus.sonar-plugins', name: 'sonar-pitest-plugin', version: '0.5'
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '3.0'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation group: 'org.testcontainers', name: 'postgresql', version: versions.testcontainers
testImplementation group: 'org.testcontainers', name: 'testcontainers', version: versions.testcontainers
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junit
testRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-launcher', version: versions.junitPlatform
testRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-commons', version: versions.junitPlatform
integrationTestImplementation group: 'org.testcontainers', name: 'testcontainers', version: versions.testcontainers
integrationTestImplementation group: 'org.testcontainers', name: 'postgresql', version: versions.testcontainers
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
functionalTestImplementation sourceSets.main.runtimeClasspath
functionalTestImplementation sourceSets.test.runtimeClasspath
functionalTestCompileOnly group: 'org.projectlombok', name: 'lombok', version: versions.lombok
functionalTestAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
smokeTestImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
smokeTestImplementation group: 'io.rest-assured', name: 'rest-assured-common', version: versions.restAssured
smokeTestImplementation group: 'io.rest-assured', name: 'json-path', version: versions.restAssured
smokeTestImplementation group: 'io.rest-assured', name: 'xml-path', version: versions.restAssured
smokeTestImplementation sourceSets.main.runtimeClasspath
smokeTestImplementation sourceSets.test.runtimeClasspath
}
test {
useJUnitPlatform()
failFast = true
}
flyway {
url = System.getenv('FLYWAY_URL')
user = System.getenv('FLYWAY_USER')
password = System.getenv('FLYWAY_PASSWORD')
baselineOnMigrate = true
baselineVersion = '000'
}
import org.flywaydb.gradle.task.FlywayMigrateTask
task migratePostgresDatabase(type: FlywayMigrateTask) {
baselineOnMigrate = true
if (project.hasProperty("dburl")) {
url = "jdbc:postgresql://${dburl}"
}
}
application {
mainClass = 'uk.gov.hmcts.reform.pcqbackend.Application'
}
bootJar {
archiveFileName = 'pcq-backend.jar'
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
rootProject.tasks.named("processTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processFunctionalTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processIntegrationTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processSmokeTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processResources") {
dependsOn("generateGitProperties")
}