forked from hmcts/wa-task-management-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
483 lines (395 loc) · 17 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
472
473
474
475
476
477
478
479
480
481
482
483
plugins {
id 'idea'
id 'application'
id 'checkstyle'
id 'pmd'
id 'jacoco'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.springframework.boot' version '2.7.11'
id 'org.owasp.dependencycheck' version '8.2.1'
id 'com.github.ben-manes.versions' version '0.42.0'
id 'org.sonarqube' version '3.2.0'
id 'info.solidsoft.pitest' version '1.9.11'
id 'io.freefair.lombok' version '6.5.1'
// If Pact version is changed, make sure serenity report works.
id 'au.com.dius.pact' version '4.3.12'
id 'net.serenity-bdd.serenity-gradle-plugin' version '3.2.0'
id 'org.flywaydb.flyway' version '9.3.0'
}
group = 'uk.gov.hmcts.reform'
version = '0.0.1'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
// https://github.com/gradle/gradle/issues/16791
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
sourceSets {
testUtils {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/testUtils/java')
}
resources.srcDir file('src/testUtils/resources')
}
functionalTest {
java {
compileClasspath += testUtils.output
runtimeClasspath += testUtils.output
srcDir file('src/functionalTest/java')
}
resources.srcDir file('src/functionalTest/resources')
}
integrationTest {
java {
compileClasspath += testUtils.output
runtimeClasspath += testUtils.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')
}
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/contractTest/java')
}
resources.srcDir file('src/contractTest/resources')
}
}
tasks.withType(Copy) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror"
}
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
showStandardStreams = true
}
}
test {
failFast = true
}
task functional(type: Test) {
maxParallelForks = (System.getenv('MAX_FT_TESTS_PARALLEL_FORKS') ? System.getenv('MAX_FT_TESTS_PARALLEL_FORKS') : 1) as int
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 smoke(type: Test) {
description = "Runs Smoke Tests"
testClassesDirs = sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
}
project.ext {
pacticipant = 'wa_task_management_api'
pacticipantVersion = getCheckedOutGitCommitHash()
}
checkstyle {
maxWarnings = 0
toolVersion = '10.9.3'
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
pmd {
toolVersion = "6.40.0"
sourceSets = [sourceSets.main]
reportsDir = file("$project.buildDir/reports/pmd")
// https://github.com/pmd/pmd/issues/876
ruleSets = []
ruleSetFiles = files("config/pmd/ruleset.xml")
}
jacocoTestCoverageVerification {
violationRules {
rule {
excludes = ["com.gargoylesoftware.htmlunit.javascript.host.css.StyleAttributes"]
}
}
}
jacocoTestReport {
executionData(test, integration)
reports {
xml.required = true
csv.required = false
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
pitest {
junit5PluginVersion = '1.0.0'
targetClasses = ['uk.gov.hmcts.reform.wataskmanagementapi.*']
excludedClasses = [
'uk.gov.hmcts.reform.wataskmanagementapi.taskconfiguration.config.*',
'uk.gov.hmcts.reform.wataskmanagementapi.config.*',
'uk.gov.hmcts.reform.wataskmanagementapi.Application'
]
threads = 10
outputFormats = ['XML', 'HTML']
timestampedReports = false
mutationThreshold = 80
}
task tests {
description = "Runs junit , integration and functional tests"
dependsOn test, integration, functional
}
project.tasks['pitest'].group = "Verification"
project.tasks['sonarqube'].dependsOn test, integration, jacocoTestReport
// Ensures that functional tests index page is generated
// Functional tests should run two tasks "functional" and "aggregate"
gradle.startParameter.continueOnFailure = true
functional.finalizedBy aggregate
sonarqube {
properties {
property "sonar.projectName", "Reform :: wa-task-management-api"
property "sonar.projectKey", "uk.gov.hmcts.reform:wa-task-management-api"
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/wataskmanagementapi/config/**," +
"src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/Application.java," +
"src/testUtils/java/uk/gov/hmcts/reform/wataskmanagementapi/**," +
"src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/clients/**," +
"src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/domain/entities/search/parameter/**," +
"src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/cft/replicarepository/**"
property "sonar.cpd.exclusions", "src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/services/calendar/**"
}
}
// 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 {
suppressionFile = 'config/owasp/suppressions.xml'
//CVE Scanning only relevant to production code that is published, not test or other implementations
scanConfigurations += 'releaseCompileClasspath'
analyzers {
// Disable scanning of .NET related binaries
assemblyEnabled = false
}
}
dependencyManagement {
dependencies {
dependency group: 'commons-io', name: 'commons-io', version: '2.8.0'
dependencySet( group: 'org.springframework.security', version: '5.7.10'){
entry 'spring-security-core'
entry 'spring-security-acl'
entry 'spring-security-aspects'
entry 'spring-security-cas'
entry 'spring-security-config'
entry 'spring-security-crypto'
entry 'spring-security-data'
entry 'spring-security-ldap'
entry 'spring-security-messaging'
entry 'spring-security-oauth2-client'
entry 'spring-security-oauth2-core'
entry 'spring-security-oauth2-jose'
entry 'spring-security-oauth2-resource-server'
entry 'spring-security-openid'
entry 'spring-security-remoting'
entry 'spring-security-rsocket'
entry 'spring-security-saml2-service-provider'
entry 'spring-security-taglibs'
entry 'spring-security-test'
entry 'spring-security-web'
}
dependencySet(group: 'org.seleniumhq.selenium', version: '4.2.2') {
entry 'selenium-java'
entry 'selenium-remote-driver'
entry 'selenium-firefox-driver'
entry 'selenium-chrome-driver'
entry 'selenium-safari-driver'
entry 'selenium-edge-driver'
entry 'selenium-api'
entry 'selenium-support'
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
}
def versions = [
junit : '5.9.0',
junitPlatform : '1.9.2',
reformLogging : '5.1.9',
springDoc : '1.6.15',
serenity : '3.1.20',
gradlePitest : '1.9.11',
pitest : '1.9.5',
sonarPitest : '0.5',
pactVersion : '4.3.4',
logbook : '2.6.2',
tomcat : '9.0.75',
testcontainers: '1.17.6'
]
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}"
]
]
ext['snakeyaml.version'] = '1.33'
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 group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-cache'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-oauth2-client', version: '2.7.11'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-oauth2-resource-server'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '3.1.6'
implementation('org.springframework.retry:spring-retry')
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: versions.springDoc
implementation group: 'org.springdoc', name: 'springdoc-openapi-webmvc-core', version: versions.springDoc
implementation group: 'org.zalando', name: 'logbook-spring-boot-starter', version: versions.logbook
implementation group: 'org.zalando', name: 'problem-spring-web-starter', version: '0.26.2'
implementation group: 'net.minidev', name: 'json-smart', version: '2.4.10'
implementation group: 'com.launchdarkly', name: 'launchdarkly-java-server-sdk', version: '6.2.1'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.reformLogging
implementation group: 'org.hibernate', name: 'hibernate-core', version: '5.6.15.Final'
implementation group: 'org.hibernate', name: 'hibernate-validator', version: '7.0.5.Final'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.19.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: '2.19.0'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: versions.tomcat
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: versions.tomcat
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '3.1.4'
implementation group: 'com.github.hmcts', name: 'core-case-data-store-client', version: '4.9.1'
implementation group: 'com.auth0', name: 'java-jwt', version: '4.4.0'
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-paranamer', version: '2.14.2'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '8.5.13'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.5.1'
// required to convert postgres to hibernate types
implementation group: 'com.vladmihalcea', name: 'hibernate-types-52', version: '2.21.1'
implementation group: 'org.awaitility', name: 'awaitility', version: '4.2.0'
implementation 'com.microsoft.azure:applicationinsights-core:2.6.0'
//cache
implementation group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '3.1.5'
testImplementation group: 'org.testcontainers', name: 'postgresql', version: versions.testcontainers
testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: versions.testcontainers
testImplementation group: 'com.h2database', name: 'h2', version: '2.1.214'
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.github.tomakehurst', name: 'wiremock-jre8', version: '2.33.2') {
exclude group: 'com.github.jknack.handlebars.java'
}
testImplementation group: 'com.github.hmcts', name: 'document-management-client', version: '7.0.1'
testImplementation group: 'org.pitest', name: 'pitest', version: versions.pitest
testImplementation group: 'info.solidsoft.gradle.pitest', name: 'gradle-pitest-plugin', version: versions.gradlePitest
testImplementation group: 'org.codehaus.sonar-plugins', name: 'sonar-pitest-plugin', version: '0.5'
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.junit.vintage', name: 'junit-vintage-engine', version: versions.junit
testImplementation group: 'com.obsidiandynamics.pojotester', name: 'core', version: '0.9.0'
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.3.0'
testImplementation group: 'com.google.guava', name: 'guava-testlib', version: '32.1.2-jre'
//Pact contract testing
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: versions.pactVersion
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit', version: versions.pactVersion
contractTestImplementation group: 'au.com.dius.pact.provider', name: 'junit5', version: versions.pactVersion
contractTestImplementation group: 'au.com.dius.pact.provider', name: 'spring', version: versions.pactVersion
contractTestImplementation group: 'au.com.dius.pact.provider', name: 'junit5spring', version: versions.pactVersion
contractTestRuntimeOnly(group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junit)
contractTestImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit)
testUtilsImplementation sourceSets.main.runtimeClasspath
testUtilsImplementation sourceSets.test.runtimeClasspath
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
functionalTestImplementation sourceSets.main.runtimeClasspath
functionalTestImplementation sourceSets.test.runtimeClasspath
smokeTestImplementation sourceSets.main.runtimeClasspath
smokeTestImplementation sourceSets.test.runtimeClasspath
contractTestImplementation sourceSets.main.runtimeClasspath
contractTestImplementation sourceSets.test.runtimeClasspath
}
task runAndPublishConsumerPactTests(type: Test) {
logger.lifecycle("Runs pact Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
runAndPublishConsumerPactTests.finalizedBy pactPublish
pact {
broker {
pactBrokerUrl = System.getenv("PACT_BROKER_FULL_URL") ?: 'http://localhost:80'
}
publish {
pactDirectory = 'build/pacts'
tags = [System.getenv("PACT_BRANCH_NAME") ?: 'Dev']
version = project.pacticipantVersion
}
}
task contract(type: Test) {
description = "Runs the consumer Pact tests"
group = 'Verification'
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
task runProviderPactVerification(type: Test) {
logger.lifecycle("Runs provider pact Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
systemProperty 'pact.verifier.publishResults', System.getProperty('pact.verifier.publishResults')
systemProperty 'pact.provider.version', project.pacticipantVersion
}
//task fortifyScan(type: JavaExec) {
// main = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
// classpath += sourceSets.test.runtimeClasspath
// jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
//}
runProviderPactVerification.dependsOn contract
runProviderPactVerification.finalizedBy pactVerify
static def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}
mainClassName = 'uk.gov.hmcts.reform.wataskmanagementapi.Application'
bootJar {
getArchiveFileName().set(provider {
'wa-task-management-api.jar'
})
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}