-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
407 lines (338 loc) · 14.5 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
buildscript {
ext {
flywayVersion = '10.17.3'
postgresqlVersion = '42.7.4'
}
dependencies {
classpath("org.postgresql:postgresql:$postgresqlVersion") // must be compatible with flyway version
classpath("org.flywaydb:flyway-database-postgresql:$flywayVersion") // flyway dependency/plugin versions must always match
}
}
plugins {
id 'application'
id 'checkstyle'
id 'pmd'
id 'jacoco'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.flywaydb.flyway' version "$flywayVersion"
id 'org.springframework.boot' version '3.3.5'
id 'org.owasp.dependencycheck' version '9.1.0'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonarqube' version '5.0.0.4638'
id 'info.solidsoft.pitest' version '1.15.0'
id 'au.com.dius.pact' version '4.6.15'
}
group = 'uk.gov.hmcts.reform'
version = '0.1.0' // all the time it was 0.0.1. 0.1.0 marks migration to java 11
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
sourceSets {
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
functionalTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
integrationTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
smokeTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror"
}
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
test {
failFast = true
}
task contract(type: Test, description: 'Runs the contract tests.', group: 'Verification') {
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
task runAndPublishConsumerPactTests(type: Test){
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
runAndPublishConsumerPactTests.finalizedBy pactPublish
task functional(type: Test, description: 'Runs the functional tests.', group: 'Verification') {
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}
task integration(type: Test, description: 'Runs the integration tests.', group: 'Verification') {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
// 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
}
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
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 = '9.3'
// need to set configDir to rootDir otherwise submodule will use submodule/config/checkstyle
configDirectory.set(new File(rootDir, 'config/checkstyle'))
}
pmd {
toolVersion = "6.55.0"
ignoreFailures = true
sourceSets = [sourceSets.main, sourceSets.test, sourceSets.functionalTest, sourceSets.integrationTest, sourceSets.smokeTest]
reportsDir = layout.buildDirectory.dir("reports/pmd").get().asFile
ruleSetFiles = files("config/pmd/ruleset.xml")
ruleSets = []
}
jacocoTestReport {
executionData(test, integration)
reports {
xml.required.set(true)
csv.required.set(false)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml"))
}
afterEvaluate {
getClassDirectories().from = getClassDirectories().files.collect {
fileTree(dir: it, exclude: [
'uk/gov/hmcts/reform/bulkscanprocessor/config/**'
])
}
}
}
project.tasks['sonarqube'].dependsOn jacocoTestReport
pitest {
group = "Verification"
pitestVersion.set('1.5.1')
junit5PluginVersion.set('0.15')
testSourceSets = [sourceSets.test]
mainSourceSets = [sourceSets.main]
// targetClasses = ['uk.gov.hmcts.reform.bulkscanprocessor.*']
// excludedClasses = [
// 'uk.gov.hmcts.reform.bulkscanprocessor.config.*'
// ]
threads = 15
enableDefaultIncrementalAnalysis = true
historyInputLocation = 'build/reports/pitest/fastermutationtesting'
historyOutputLocation = 'build/reports/pitest/fastermutationtestingoutput'
outputFormats = ['XML', 'HTML']
timestampedReports = false
mutationThreshold = 0
coverageThreshold = 0
failWhenNoMutations = false
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'
])
}
sonarqube {
properties {
property "sonar.projectName", "Reform :: Bulk Scan Processor"
property "sonar.coverage.jacoco.xmlReportPaths", jacocoTestReport.reports.xml.outputLocation.get().asFile.absolutePath
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
property "sonar.exclusions", "**/model/out/*,**/config/**,**/LeaseAcquirer.java"
}
}
pact {
publish {
pactBrokerUrl = 'https://pact-broker.platform.hmcts.net'
version = '0.0.1'
}
}
// 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
}
}
// it is important to specify logback classic and core packages explicitly as libraries like spring boot
// enforces it's own (older) version which is not recommended.
def versions = [
junit: '5.9.2',
junitPlatform: '1.9.2',
mockitoJupiter: '3.3.3',
reformLogging: '6.0.1',
apiguardian : '1.1.2',
flyway: "$flywayVersion",
postgresql: "$postgresqlVersion"
]
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
}
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.apiguardian:apiguardian-api:${versions.apiguardian}"
]
]
ext["rest-assured.version"] = '5.4.0'
dependencies {
def withoutJavaxMailApi = {
exclude group: 'javax.mail', module: 'mailapi'
}
runtimeOnly group: 'org.flywaydb', name: 'flyway-database-postgresql', version: versions.flyway
implementation group: 'org.flywaydb', name: 'flyway-core', version: versions.flyway
implementation group: 'org.postgresql', name: 'postgresql', version: versions.postgresql
implementation group: 'net.javacrumbs.shedlock', name: 'shedlock-spring', version: '5.14.0'
implementation group: 'net.javacrumbs.shedlock', name: 'shedlock-provider-jdbc', version: '5.14.0'
implementation group: 'com.azure', name: 'azure-storage-blob', version: '12.28.1'
implementation group: 'com.azure', name: 'azure-messaging-servicebus', version: '7.17.5'
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-data-jpa'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-activemq'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '4.1.3'
implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: '13.3'
implementation group: 'io.github.openfeign', name: 'feign-jackson', version: '13.3'
implementation group: 'com.github.java-json-tools', name: 'json-schema-validator', version: '2.2.14', withoutJavaxMailApi
// review following dependency after integrating db structure
implementation group: 'io.hypersistence', name: 'hypersistence-utils-hibernate-63', version: '3.8.3'
implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.3.1'
implementation group: 'javax.jms', name: 'javax.jms-api', version: '2.0.1'
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.6.0'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.reformLogging
implementation group: 'com.github.hmcts.java-logging', name: 'logging-appinsights', version: versions.reformLogging
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.0'
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '4.1.2'
implementation group: 'com.github.hmcts', name: 'idam-java-client', version: '3.0.3'
implementation group: 'com.github.hmcts', name: 'ccd-case-document-am-client', version: '1.59'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: '3.1.9'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.17.0'
// only used in uk.gov.hmcts.reform.bulkscanprocessor.validation.OcrValidator
// single import: io.vavr.control.Try
implementation group: 'io.vavr', name: 'vavr', version: '0.10.5'
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.12.0'
implementation group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '3.1.8'
implementation group: 'io.github.resilience4j', name: 'resilience4j-spring-boot2', version: '2.2.0'
implementation group: 'com.launchdarkly', name: 'launchdarkly-java-server-sdk', version: '7.6.0'
implementation group: 'com.google.guava', name: 'guava', version: '33.3.1-jre'
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: 'com.jayway.awaitility', name: 'awaitility', version: '1.7.0'
testImplementation group: 'com.icegreen', name: 'greenmail', version: '1.6.15', {
exclude group: 'junit', module: 'junit'
}
testImplementation group: 'org.apache.commons', name: 'commons-email', version: '1.6.0'
testImplementation group: 'io.github.netmikey.logunit', name: 'logunit-core', version: '2.0.0'
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.5', classifier: 'all', {
exclude group: 'commons-io', module: 'commons-io'
exclude group: 'org.apache.commons', module: 'commons-lang3'
}
testImplementation group: 'com.icegreen', name: 'greenmail', version: '2.1.0'
testRuntimeOnly group: 'io.github.netmikey.logunit', name: 'logunit-logback', version: '2.0.0'
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
integrationTestImplementation group: 'org.springframework.cloud', name: 'spring-cloud-contract-wiremock', version: '4.1.4', {
exclude group: 'com.github.tomakehurst', module: 'wiremock-jre8-standalone'
}
integrationTestImplementation group: 'org.wiremock', name: 'wiremock-standalone', version: '3.9.2'
integrationTestImplementation group: 'org.testcontainers', name: 'postgresql', version: '1.19.7', {
exclude group: 'junit', module: 'junit'
}
integrationTestImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.1'
integrationTestImplementation group: 'com.revinate', name: 'assertj-json', version: '1.2.0'
functionalTestImplementation sourceSets.main.runtimeClasspath
functionalTestImplementation sourceSets.smokeTest.runtimeClasspath
smokeTestImplementation sourceSets.main.runtimeClasspath
smokeTestImplementation sourceSets.test.runtimeClasspath
smokeTestImplementation group: 'io.rest-assured', name: 'rest-assured'
functionalTestImplementation group: 'com.typesafe', name: 'config', version: '1.4.3'
contractTestImplementation sourceSets.main.runtimeClasspath
contractTestImplementation sourceSets.test.runtimeClasspath
contractTestImplementation group: 'io.rest-assured', name: 'rest-assured'
contractTestImplementation group: 'au.com.dius', name: 'pact-jvm-consumer-junit5', version: '4.0.10'
}
mainClassName = 'uk.gov.hmcts.reform.bulkscanprocessor.Application'
bootJar {
getArchiveFileName().set(provider {
'bulk-scan-processor.jar'
})
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
import org.flywaydb.gradle.task.FlywayMigrateTask
flyway {
url = System.getenv('FLYWAY_URL')
user = System.getenv('FLYWAY_USER')
password = System.getenv('FLYWAY_PASSWORD')
baselineOnMigrate = true
baselineVersion = '000'
}
task migratePostgresDatabase(type: FlywayMigrateTask) {
baselineOnMigrate = true
if (project.hasProperty("dburl")) {
url = "jdbc:postgresql://${dburl}"
}
}