-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
431 lines (359 loc) · 14.6 KB
/
build.gradle
File metadata and controls
431 lines (359 loc) · 14.6 KB
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
buildscript {
dependencies {
classpath("org.flywaydb:flyway-database-postgresql:11.20.3")
}
}
plugins {
id 'application'
id 'checkstyle'
id 'pmd'
id 'jacoco'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.springframework.boot' version '3.5.6'
id 'org.owasp.dependencycheck' version '12.2.0'
id 'com.github.ben-manes.versions' version '0.53.0'
id 'org.sonarqube' version '6.3.1.5724'
id "io.freefair.lombok" version "9.0.0"
id 'org.flywaydb.flyway' version '11.20.3'
id "info.solidsoft.pitest" version '1.15.0'
}
group = 'uk.gov.hmcts.reform'
version = '0.0.1'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
sourceSets {
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')
}
buildOpenApiSpecs {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/buildOpenApiSpecs/java')
}
resources.srcDir file('src/buildOpenApiSpecs/resources')
}
smokeTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/smokeTest/java')
}
resources.srcDir file('src/smokeTest/resources')
}
}
configurations {
functionalTestImplementation.extendsFrom testImplementation
functionalTestRuntimeOnly.extendsFrom runtimeOnly
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom runtimeOnly
buildOpenApiSpecsImplementation.extendsFrom testImplementation
buildOpenApiSpecsRuntimeOnly.extendsFrom runtimeOnly
smokeTestImplementation.extendsFrom testImplementation
smokeTestRuntimeOnly.extendsFrom runtimeOnly
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror"
}
// https://github.com/gradle/gradle/issues/16791
//tasks.withType(JavaExec).configureEach {
// javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
//}
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 integration(type: Test) {
description = "Runs integration tests"
group = "Verification"
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
failFast = true
}
task buildOpenApiSpecs(type: Test) {
description = "Builds OpenAPI specs"
group = "Verification"
testClassesDirs = sourceSets.buildOpenApiSpecs.output.classesDirs
classpath = sourceSets.buildOpenApiSpecs.runtimeClasspath
failFast = true
}
task smoke(type: Test) {
description = "Runs Smoke Tests"
testClassesDirs = sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
}
task fortifyScan(type: JavaExec) {
main = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
checkstyle {
maxWarnings = 0
toolVersion = '11.1.0'
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
pmd {
toolVersion = "7.17.0"
sourceSets = [sourceSets.main]
// https://github.com/pmd/pmd/issues/876
ruleSets = []
ruleSetFiles = files("${rootDir}/config/pmd/ruleset.xml")
pmdMain {
excludes = [
'**/batch/**',
'**/migration/**'
]
}
}
jacocoTestReport {
executionData(test, integration)
reports {
xml.required = true
csv.required = false
html.required = true
}
}
flyway {
url = System.getenv('POSTGRES_HOST') ?: "jdbc:postgresql://localhost:5432/api"
user = System.getenv('POSTGRES_USER') ?: "pre"
password = System.getenv('POSTGRES_PASSWORD') ?: "pre"
baselineOnMigrate = true
baselineVersion = '000'
}
pitest {
targetClasses = ['uk.gov.hmcts.reform.*']
junit5PluginVersion = '1.2.1'
pitestVersion = '1.15.2'
excludedClasses = [
'uk.gov.hmcts.reform.preapi.Application.java'
]
useClasspathFile = true
enableDefaultIncrementalAnalysis = true
historyInputLocation = 'build/reports/pitest/fastermutationtesting'
historyOutputLocation ='build/reports/pitest/fastermutationtestingoutput'
threads = 15
testSourceSets = [sourceSets.test]
mainSourceSets = [sourceSets.main]
fileExtensionsToFilter.addAll('xml','json')
outputFormats = ['XML', 'HTML','CSV']
mutationThreshold = 5
coverageThreshold = 0
jvmArgs = ['-Xms1G','-Xmx3G']
timestampedReports = false
failWhenNoMutations = false
detectInlinedCode = true
}
task migratePostgresDatabase(type: org.flywaydb.gradle.task.FlywayMigrateTask) {
baselineOnMigrate = true
if (project.hasProperty("dburl")) {
url = "jdbc:postgresql://${dburl}"
}
}
project.tasks['sonarqube'].dependsOn jacocoTestReport
project.tasks['check'].dependsOn integration
def coverageExclusionList = [
'**uk/gov/hmcts/reform/preapi/data/exception/PendingMigrationScriptException*',
'**uk/gov/hmcts/reform/preapi/data/migration/FlywayNoOpStrategy*',
'**uk/gov/hmcts/reform/preapi/batch/**',
'**uk/gov/hmcts/reform/preapi/dto/migration/**',
'**uk/gov/hmcts/reform/preapi/tasks/migration/**',
'**uk/gov/hmcts/reform/preapi/controllers/TestingSupportController*',
'**/uk/gov/hmcts/reform/preapi/Application.java',
]
def duplicateCodeExclusionList = [
'**uk/gov/hmcts/reform/preapi/entities/**',
'**uk/gov/hmcts/reform/preapi/controllers/LegacyReportController*',
'**uk/gov/hmcts/reform/preapi/services/LegacyReportService*',
'**uk/gov/hmcts/reform/preapi/dto/base/BaseUserDTO*'
]
sonarqube {
properties {
property "sonar.projectName", "Reform :: pre-api"
property "sonar.projectKey", "uk.gov.hmcts.reform:pre-api"
property "sonar.exclusions", coverageExclusionList.join(", ")
property "sonar.cpd.exclusions", duplicateCodeExclusionList.join(", ")
}
}
// 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 = 0
suppressionFile = 'config/owasp/suppressions.xml'
analyzers {
// Disable scanning of .NET related binaries
assemblyEnabled = false
}
skipConfigurations = [
"checkstyle",
"compileOnly",
"pmd",
"integrationTest",
"buildOpenApiSpecs",
"functionalTest",
"smokeTest",
"contractTestRuntimeClasspath",
"contractTestCompileClasspath"
]
}
repositories {
mavenLocal()
mavenCentral()
maven {url 'https://pkgs.dev.azure.com/hmcts/Artifacts/_packaging/hmcts-lib/maven/v1' }
}
def versions = [
jackson : '2.20.0',
jacksonAnnot : '2.20',
junit : '5.14.2',
junitPlatform : '1.14.2',
restAssured : '5.5.7',
springBoot : springBoot.class.package.implementationVersion,
testcontainers : '1.21.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}",
"org.junit.platform:junit-platform-launcher:${versions.junitPlatform}"
]
]
ext['snakeyaml.version'] = '2.0'
dependencyManagement {
imports {
mavenBom "org.testcontainers:testcontainers-bom:${versions.testcontainers}"
}
}
dependencies {
implementation 'com.microsoft.azure:applicationinsights-core:3.7.7'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: versions.springBoot
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: versions.springBoot
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: versions.springBoot
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-json', version: versions.springBoot
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: versions.springBoot
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: versions.springBoot
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: versions.springBoot
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-batch', version: versions.springBoot
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.8.15'
implementation group: 'org.springframework.hateoas', name: 'spring-hateoas', version: '2.5.1'
implementation group: 'com.azure.spring', name: 'spring-cloud-azure-starter-active-directory', version: '6.2.0'
implementation group: 'org.apache.commons', name: 'commons-exec', version: '1.5.0'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '11.20.3'
implementation group: 'org.flywaydb', name: 'flyway-database-postgresql', version: '11.20.3'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.7.9'
implementation group: 'io.hypersistence', name: 'hypersistence-utils-hibernate-63', version: '3.11.0'
implementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
implementation 'io.github.openfeign:feign-gson:13.6'
implementation 'io.github.openfeign:feign-slf4j:13.6'
implementation group: 'io.github.openfeign', name: 'feign-jackson', version: '13.6'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '4.3.0'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-loadbalancer', version: '4.3.0'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', 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.jacksonAnnot
implementation group: 'com.opencsv', name: 'opencsv', version: '5.12.0'
implementation group: 'com.azure', name: 'azure-storage-blob', version: '12.33.3'
implementation group: 'com.azure', name: 'azure-core-serializer-json-jackson', version: '1.6.3'
implementation group: 'com.azure.resourcemanager', name: 'azure-resourcemanager-mediaservices', version: '2.4.0'
implementation group: 'org.testcontainers', name: 'postgresql', version: versions.testcontainers
implementation group: 'com.auth0', name: 'java-jwt', version: '4.5.0'
implementation group: 'uk.gov.service.notify', name: 'notifications-java-client', version: '5.2.1-RELEASE'
implementation group: 'com.microsoft.graph', name: 'microsoft-graph', version: '6.24.0'
implementation group: 'com.azure', name: 'azure-identity', version: '1.18.2'
implementation group: 'org.jsoup', name: 'jsoup', version: '1.22.1'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor('org.hibernate.orm:hibernate-jpamodelgen:6.6.42.Final')
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'com.github.hmcts:fortify-client:1.4.10:all'
testImplementation 'org.springframework.security:spring-security-test:6.5.8'
testRuntimeOnly('org.springframework.security:spring-security-web:6.5.8')
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'
}, version: versions.springBoot
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
integrationTestImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: versions.testcontainers
buildOpenApiSpecsImplementation sourceSets.main.runtimeClasspath
buildOpenApiSpecsImplementation sourceSets.test.runtimeClasspath
buildOpenApiSpecsImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: versions.testcontainers
functionalTestImplementation sourceSets.main.runtimeClasspath
functionalTestImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: versions.springBoot
functionalTestImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
functionalTestImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: versions.testcontainers
smokeTestImplementation sourceSets.main.runtimeClasspath
smokeTestImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: versions.springBoot
smokeTestImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
}
rootProject.tasks.named("processBuildOpenApiSpecsResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processIntegrationTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processFunctionalTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processSmokeTestResources") {
duplicatesStrategy = 'include'
}
mainClassName = 'uk.gov.hmcts.reform.preapi.Application'
bootJar {
archiveFileName = "pre-api.jar"
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
bootRun {
debugOptions {
port = 2025
}
}
// Gradle 7.x issue, workaround from: https://github.com/gradle/gradle/issues/17236#issuecomment-894768083
rootProject.tasks.named("processSmokeTestResources") {
duplicatesStrategy = 'include'
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}