forked from hmcts/prl-cos-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
487 lines (420 loc) · 18.8 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
484
485
486
487
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:2.4.24")
}
}
plugins {
id 'application'
id 'checkstyle'
id 'com.github.ben-manes.versions' version '0.39.0'
id 'info.solidsoft.pitest' version '1.6.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'jacoco'
id 'org.owasp.dependencycheck' version '6.2.2'
id 'org.sonarqube' version '3.2.0'
id 'org.springframework.boot' version '2.5.4'
id 'au.com.dius.pact' version '4.2.6'
}
def versions = [
awaitility : '4.0.2',
bcpkixJdk15on : '1.64',
ccdClient : '4.7.6',
commonsBeanUtils : '1.9.4',
commonsIo : '2.7',
commonsLang3 : '3.9',
commonsMath3 : '3.6.1',
dumbster : '1.7.1',
feignHttpClient : '10.3.0',
googleAuth : '1.5.0',
guava : '30.1-jre',
hmctsNotify : '3.14.1-RELEASE',
// idamClient : '1.3.0',
httpComponents : '4.5.13',
jackson : '2.12.3',
jacksonDatatypeJsr : '2.12.3',
jsonAssert : '1.2.3',
// jsonPathAssert : '2.2.0',
junit : '4.13.1',
junitPlatform : '5.7.2',
lombok : '1.18.20',
pact : '4.1.11',
puppyCrawl : '8.43',
reformPropertiesVolume : '0.0.4',
reformsJavaLogging : '5.1.7',
sendLetterClient : '2.2.0',
serenity : '2.3.10',
serenityCucumber : '1.9.50',
serviceTokenGenerator : '3.1.1',
springfoxSwagger : '3.0.0',
springSecurityCrypto : '5.4.5',
springSecurityRsa : '1.0.9.RELEASE',
springBoot : '2.5.4',
springCloud : '3.0.3',
tomcat : '9.0.54',
unirest : '1.4.9'
]
allprojects {
def springBootVersion = versions.springBoot
apply plugin: 'checkstyle'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply plugin: 'java'
apply plugin: 'org.owasp.dependencycheck'
group = 'uk.gov.hmcts.reform.prl'
version = '0.0.1'
checkstyle.toolVersion = '8.34'
checkstyle.configFile = new File(rootDir, "config/checkstyle/checkstyle.xml")
checkstyle.configDir(rootDir)
checkstyle.maxWarnings(0)
// 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') == 'false' ? 11 : 0
suppressionFile = 'config/checkstyle/checkstyle.xml'
analyzers {
// Disable scanning of .NET related binaries
assemblyEnabled = false
}
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
jcenter()
maven { url 'https://repo.spring.io/libs-milestone' }
}
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
}
dependencies {
dependencySet(
group: 'com.fasterxml.jackson.core',
version: versions.jackson
) {
entry 'jackson-core'
entry 'jackson-databind'
}
dependencySet(
group: 'com.fasterxml.jackson.datatype',
version: versions.jackson
) {
entry 'jackson-datatype-jdk8'
entry 'jackson-datatype-jsr310'
}
dependencySet(
group: 'com.fasterxml.jackson.module',
version: versions.jackson
) {
entry 'jackson-module-parameter-names'
}
// solves CVE-2014-3488, CVE-2015-2156, CVE-2019-16869, CVE-2021-21409
dependencySet(group: 'io.netty', version: '4.1.65.Final') {
entry 'netty-buffer'
entry 'netty-codec'
entry 'netty-codec-http'
entry 'netty-common'
entry 'netty-handler'
entry 'netty-resolver'
entry 'netty-transport'
}
// CVE-2019-10086
dependency group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
// CVE-2020-9484
dependencySet(group: 'org.apache.tomcat.embed', version: versions.tomcat) {
entry 'tomcat-embed-core'
entry 'tomcat-embed-websocket'
entry 'tomcat-embed-el'
}
//CVE-2017-18640
dependency group: 'org.yaml',name: 'snakeyaml', version: '1.26'
}
}
}
apply plugin: 'net.serenity-bdd.aggregator'
group = 'uk.gov.hmcts.reform.prl'
version = '0.0.1'
sourceCompatibility = 11
mainClassName = 'uk.gov.hmcts.reform.prl.Application'
bootJar {
getArchiveFileName().set(provider {
'prl-cos-api.jar'
})
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
compileJava {
options.compilerArgs << '-parameters' << '-Xlint:deprecation'
}
compileTestJava {
options.compilerArgs << '-Xlint:deprecation'
}
distributions {
main {
contents {
from(file("$projectDir/lib/AI-Agent.xml")) {
into "lib"
}
}
}
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir('src/integrationTest/java')
}
resources {
srcDir('src/integrationTest/resources')
}
}
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/contractTest/java')
}
resources.srcDir file('src/contractTest/resources')
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntime.extendsFrom testRuntime
}
// 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
}
}
dependencies {
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
compileOnly("org.projectlombok:lombok:${versions.lombok}")
testCompileOnly("org.projectlombok:lombok:${versions.lombok}")
annotationProcessor("org.projectlombok:lombok:${versions.lombok}")
testAnnotationProcessor("org.projectlombok:lombok:${versions.lombok}")
implementation group: 'junit', name: 'junit', version: versions.junit
implementation group: 'com.sun.xml.bind', name: 'jaxb-osgi', version: '2.3.3'
implementation group: 'com.github.kirviq', name: 'dumbster', version: versions.dumbster
implementation group: 'com.puppycrawl.tools', name: 'checkstyle', version: versions.puppyCrawl
implementation group: 'commons-io', name: 'commons-io', version: versions.commonsIo
implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: versions.feignHttpClient
implementation group: 'io.springfox', name: 'springfox-swagger2', version: versions.springfoxSwagger
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: versions.springfoxSwagger
implementation group: 'jakarta.activation', name: 'jakarta.activation-api', version: '2.0.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: versions.commonsLang3
implementation group: 'org.apache.commons', name: 'commons-math3', version: versions.commonsMath3
implementation group: 'org.springframework', name: 'spring-context-support', version: '5.3.8'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: versions.springBoot
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: versions.springBoot
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: versions.springCloud
implementation group: 'org.springframework.retry', name: 'spring-retry'
implementation group: 'com.github.hmcts', name: 'ccd-client', version: versions.ccdClient
implementation group: 'uk.gov.hmcts.reform', name: 'logging', version: versions.reformsJavaLogging
implementation group: 'uk.gov.hmcts.reform', name: 'logging-appinsights', version: versions.reformsJavaLogging
implementation group: 'uk.gov.hmcts.reform', name: 'logging-httpcomponents', version: versions.reformsJavaLogging
implementation group: 'uk.gov.hmcts.reform', name: 'logging-spring', version: versions.reformsJavaLogging
implementation group: 'uk.gov.hmcts.reform', name: 'properties-volume-spring-boot-starter', version: versions.reformPropertiesVolume
implementation group: 'uk.gov.hmcts.reform', name: 'service-auth-provider-client', version: versions.serviceTokenGenerator
implementation group: 'uk.gov.hmcts.reform', name: 'send-letter-client', version: versions.sendLetterClient
implementation group: 'uk.gov.service.notify', name: 'notifications-java-client', version: versions.hmctsNotify
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: versions.httpComponents
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-quartz'
implementation group: 'uk.gov.service.notify', name: 'notifications-java-client', version: versions.hmctsNotify
implementation group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.1.1'
implementation(group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign')
{
exclude group: 'io.reactivex', module: 'io.reactivex'
exclude group: 'io.reactivex', module: 'rxnetty'
exclude group: 'io.reactivex', module: 'rxnetty-contexts'
exclude group: 'io.reactivex', module: 'rxnetty-servo'
}
implementation(group: 'commons-beanutils', name: 'commons-beanutils', version: versions.commonsBeanUtils)
implementation(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: versions.jackson)
implementation(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jackson)
implementation(group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: versions.jackson)
implementation(group: 'com.google.guava', name: 'guava', version: versions.guava)
implementation(group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: versions.bcpkixJdk15on) {
force = true
}
implementation(group: 'org.springframework.security', name: 'spring-security-rsa', version: versions.springSecurityRsa) {
force = true
}
implementation(group: 'org.springframework.security', name: 'spring-security-crypto', version: versions.springSecurityCrypto) {
force = true
}
constraints{
implementation group: 'com.warrenstrange', name: 'googleauth', version: '1.5.0'
}
runtimeOnly('org.springframework.boot:spring-boot-devtools')
testImplementation group: 'org.awaitility', name: 'awaitility', version: versions.awaitility
testImplementation group: 'org.springframework.cloud', name: 'spring-cloud-contract-wiremock', version: versions.springCloud
testImplementation(group: 'org.springframework.boot', name: 'spring-boot-starter-test') {
exclude(module: 'commons-logging')
exclude(module: 'android-json')
exclude module: 'junit'
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
// integration test
integrationTestAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
integrationTestImplementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: versions.jacksonDatatypeJsr
integrationTestImplementation group: 'com.mashape.unirest', name: 'unirest-java', version: versions.unirest
integrationTestImplementation group: 'io.github.openfeign', name: 'feign-httpclient', version: versions.feignHttpClient
integrationTestImplementation group: 'junit', name: 'junit', version: versions.junit
integrationTestImplementation group: 'net.serenity-bdd', name: 'serenity-core', version: versions.serenity
integrationTestImplementation group: 'net.serenity-bdd', name: 'serenity-cucumber', version: versions.serenityCucumber
integrationTestImplementation group: 'net.serenity-bdd', name: 'serenity-junit', version: versions.serenity
integrationTestImplementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: versions.serenity
integrationTestImplementation group: 'net.serenity-bdd', name: 'serenity-spring', version: versions.serenity
integrationTestImplementation group: 'org.apache.commons', name: 'commons-lang3', version: versions.commonsLang3
integrationTestImplementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
integrationTestImplementation group: 'org.skyscreamer', name: 'jsonassert', version: versions.jsonAssert
integrationTestImplementation group: 'org.springframework', name: 'spring-context-support'
integrationTestImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
integrationTestImplementation(group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign')
{
exclude group: 'io.reactivex', module: 'io.reactivex'
exclude group: 'io.reactivex', module: 'rxnetty'
exclude group: 'io.reactivex', module: 'rxnetty-contexts'
exclude group: 'io.reactivex', module: 'rxnetty-servo'
}
integrationTestImplementation(group: 'uk.gov.hmcts.reform', name: 'service-auth-provider-client', version: versions.serviceTokenGenerator)
{
exclude group: 'io.reactivex', module: 'io.reactivex'
exclude group: 'io.reactivex', module: 'rxnetty'
exclude group: 'io.reactivex', module: 'rxnetty-contexts'
exclude group: 'io.reactivex', module: 'rxnetty-servo'
}
contractTestCompile group: 'com.google.guava', name: 'guava', version: versions.guava
contractTestCompile group: 'au.com.dius.pact.consumer', name: 'junit5', version: versions.pact
contractTestCompile group: 'au.com.dius.pact.consumer', name: 'java8', version: versions.pact
contractTestRuntime group: 'com.google.guava', name: 'guava', version: versions.guava
contractTestRuntime group: 'au.com.dius.pact.consumer', name: 'junit5', version: versions.pact
contractTestRuntime group: 'au.com.dius.pact.consumer', name: 'java8', version: versions.pact
contractTestCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: versions.httpComponents
compile 'org.junit.vintage:junit-vintage-engine:5.7.2'
testRuntimeOnly "org.junit.platform:junit-platform-commons:1.7.0"
contractTestCompile("org.junit.jupiter:junit-jupiter-api:5.7.2")
contractTestRuntime("org.junit.jupiter:junit-jupiter-engine:5.7.2")
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.2"
contractTestImplementation('org.junit.jupiter:junit-jupiter-api:5.7.2')
contractTestCompile sourceSets.main.runtimeClasspath
contractTestCompile sourceSets.test.runtimeClasspath
integrationTestImplementation(sourceSets.test.output)
}
task smoke(type: Test, description: 'Runs the smoke tests.', group: 'Verification') {
useJUnit {
includeCategories 'uk.gov.hmcts.reform.prl.category.SmokeTest'
}
}
task functional(type: Test, description: 'Runs functional tests.', group: 'Verification') {
useJUnitPlatform()
setTestClassesDirs(sourceSets.integrationTest.output.classesDirs)
setClasspath(sourceSets.integrationTest.runtimeClasspath)
}
task nightlyFunctional(type: Test, description: 'Runs the Nightly Only Functional tests.', group: 'Verification') {
doFirst(){
printf(":::::::::: Running nightlyFunctional ::::::::::")
}
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
forkEvery = 10
setTestClassesDirs(sourceSets.integrationTest.output.classesDirs)
setClasspath(sourceSets.integrationTest.runtimeClasspath)
finalizedBy aggregate
}
pitest {
targetClasses = ['uk.gov.hmcts.reform.divorce.prl.*']
excludedClasses = [
'uk.gov.hmcts.reform.divorce.prl.config.*',
'uk.gov.hmcts.reform.divorce.prl.models.*',
]
threads = 10
outputFormats = ['XML', 'HTML']
timestampedReports = false
mutationThreshold = 80
}
jacocoTestReport {
executionData(test)
reports {
xml.enabled = true
csv.enabled = false
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.9
}
}
}
}
project.tasks['sonarqube'].dependsOn jacocoTestReport
def sonarExclusions = [
'**uk/gov/hmcts/reform/prl/models/**/*',
'**uk/gov/hmcts/reform/prl/config/**/*',
'**uk/gov/hmcts/reform/prl/utils/SslVerificationDisabler.*',
'**uk/gov/hmcts/reform/prl/Application.*'
]
sonarqube {
properties {
property "sonar.projectName", "Family Private Law :: prl-cos"
property "sonar.projectKey", "prl-cos-api"
property "sonar.exclusions", sonarExclusions.join(", ")
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.destination.path}"
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
}
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
def debug = System.getProperty("debug")
run {
if (debug == 'true') {
jvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5010']
}
}
task contract(type: Test, description: 'Runs the consumer Pact tests.', group: 'Delivery pipeline') {
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
include "uk/gov/hmcts/reform/prl/clients/**"
systemProperty 'pact.rootDir', "pacts"
environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
task runAndPublishConsumerPactTests(type: Test){
logger.lifecycle("Runs pact Tests")
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
}
runAndPublishConsumerPactTests.dependsOn contract
runAndPublishConsumerPactTests.finalizedBy pactPublish
project.ext {
pactVersion = getCheckedOutGitCommitHash()
}
def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}
pact {
publish {
pactDirectory = 'pacts'
pactBrokerUrl = System.getenv("PACT_BROKER_FULL_URL") ?: 'http://localhost:80'
tags = [System.getenv("PACT_BRANCH_NAME") ?:'Dev']
version = project.pactVersion
}
}