-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
306 lines (265 loc) · 12.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
plugins {
id 'application'
id 'java'
id 'jacoco'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.springframework.boot' version '3.3.5'
id 'uk.gov.hmcts.java' version '0.12.63'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'com.gorylenko.gradle-git-properties' version '2.4.2'
id 'info.solidsoft.pitest' version '1.15.0'
id 'org.sonarqube' version '6.0.1.5171'
id 'au.com.dius.pact' version '4.6.16'
id 'net.serenity-bdd.serenity-gradle-plugin' version '4.2.8'
}
application {
mainClass = 'uk.gov.hmcts.probate.BusinessApplication'
group = 'uk.gov.hmcts.probate'
version = "3.0.0"
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
jacoco {
toolVersion = '0.8.12'
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
sonar {
properties {
property "sonar.projectName", "Probate :: Business Service"
property "sonar.jacoco.reportPath", "${layout.buildDirectory.get()}/jacoco/test.exec"
property "sonar.coverage.jacoco.xmlReportPaths", "${layout.buildDirectory.get()}/jacoco/test/html/jacocoTestReport.xml"
property "sonar.host.url", "https://sonar.reform.hmcts.net/"
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
}
}
pitest {
targetClasses = ['uk.gov.hmcts.probate.*']
threads = 4
outputFormats = ['XML', 'HTML']
timestampedReports = false
mutationThreshold = 50
}
test.finalizedBy jacocoTestReport
dependencyCheck {
suppressionFile = 'config/owasp/suppressions.xml'
}
sourceSets {
testFunctional {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/functionalTest/java')
}
resources.srcDir file('src/functionalTest/resources')
}
testSmoke {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/smokeTest/java')
}
resources.srcDir file('src/smokeTest/resources')
}
testContract {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/contractTest/java')
}
resources.srcDir file('src/contractTest/resources')
}
}
task smoke(type: Test) {
description = "Runs Smoke Tests"
testClassesDirs = sourceSets.testSmoke.output.classesDirs
classpath = sourceSets.testSmoke.runtimeClasspath
}
task functional(type: Test) {
description = "Runs functional Tests"
testClassesDirs = sourceSets.testFunctional.output.classesDirs
classpath = sourceSets.testFunctional.runtimeClasspath
finalizedBy aggregate
}
functional.finalizedBy(aggregate)
tasks.withType(Test) {
maxHeapSize = "1024m"
useJUnitPlatform()
}
task pactTask(type: Test) {
description = "Runs pact Tests"
include "uk/gov/hmcts/probate/services/consumer/**"
exclude "uk/gov/hmcts/probate/services/businessdocuments/controllers/**"
testClassesDirs = sourceSets.testContract.output.classesDirs
classpath = sourceSets.testContract.runtimeClasspath
}
jacocoTestReport {
executionData(test)
reports {
xml.required = true
csv.required = false
xml.outputLocation = file("${layout.buildDirectory.get()}/reports/jacoco/test/jacocoTestReport.xml")
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
}
def versions = [
jacksonDatabind : '2.18.2',
jjwtApi : '0.12.6',
junit_jupiter : '5.10.2',
logging : '6.1.7',
lombok : '1.18.36',
pact_version : '4.1.11',
probateCommons : '2.0.31',
restAssured : '5.5.0',
serenity : '4.2.9',
serenityreporter : '4.1.6',
springBootVersion: '3.3.5',
springCloud : '4.2.0',
springDocUi : '1.8.0'
]
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2023.0.4'
}
}
dependencies {
implementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: versions.springBootVersion
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web-services', version: versions.springBootVersion
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: versions.springBootVersion
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: versions.springCloud
implementation group: 'org.springframework.retry', name: 'spring-retry'
implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.4.1'
implementation group: 'org.springframework.hateoas', name: 'spring-hateoas'
implementation group: 'org.hibernate.validator', name: 'hibernate-validator'
implementation group: 'uk.gov.service.notify', name: 'notifications-java-client', version: '5.2.1-RELEASE'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.logging
implementation group: 'com.github.hmcts.java-logging', name: 'logging-appinsights', version: versions.logging
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.3.0'
implementation group: 'com.github.hmcts', name: 'cmc-pdf-service-client', version: '8.0.1'
implementation group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.1.1'
implementation group: 'org.pitest', name: 'pitest', version: '1.17.3'
implementation 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.15.0'
implementation group: 'org.codehaus.sonar-plugins', name: 'sonar-pitest-plugin', version: '0.5'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jacksonDatabind
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: versions.jacksonDatabind
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: versions.jacksonDatabind
implementation group: 'com.github.hmcts', name: 'probate-commons', version: versions.probateCommons
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: versions.springDocUi
implementation group: 'org.springframework.cloud', name: 'spring-cloud-openfeign-core', version: versions.springCloud
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.0'
implementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
compileOnly group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: versions.springBootVersion
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit_jupiter
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junit_jupiter
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.6', classifier: 'all'
testImplementation group: 'org.apache.pdfbox', name: 'pdfbox', version: '3.0.3'
testImplementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testFunctionalImplementation group: 'net.serenity-bdd', name: 'serenity-core', version: versions.serenity
testFunctionalImplementation group: 'net.serenity-bdd', name: 'serenity-junit5', version: versions.serenity
testFunctionalImplementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: versions.serenity
testFunctionalImplementation group: 'net.serenity-bdd', name: 'serenity-spring', version: versions.serenity
testFunctionalImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
testFunctionalImplementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: versions.jjwtApi
testFunctionalImplementation group: 'com.github.hmcts', name: 'cmc-pdf-service-client', version: '8.0.1'
testFunctionalImplementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.3.0'
testFunctionalImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jacksonDatabind
testFunctionalImplementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testFunctionalAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testFunctionalImplementation sourceSets.main.runtimeClasspath
testFunctionalImplementation sourceSets.test.runtimeClasspath
testSmokeImplementation group: 'io.rest-assured', name: 'rest-assured', version: versions.restAssured
testSmokeImplementation sourceSets.main.runtimeClasspath
testSmokeImplementation sourceSets.test.runtimeClasspath
testContractImplementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: versions.jjwtApi
testContractImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: versions.springBootVersion
testContractImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit_jupiter
testContractImplementation group: 'au.com.dius.pact.provider', name: 'junit5', version: versions.pact_version
testContractImplementation group: 'au.com.dius.pact.provider', name: 'spring', version: versions.pact_version
testContractImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: versions.pact_version
testContractImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: versions.pact_version
testContractRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.7.0'
testContractImplementation sourceSets.main.runtimeClasspath
testContractImplementation sourceSets.test.runtimeClasspath
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-parameters'
}
// https://github.com/gradle/gradle/issues/16791
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
bootJar {
archiveFileName = 'business-service.jar'
manifest {
attributes 'Implementation-Title': project.name,
'Implementation-Version': project.version
}
}
project.ext {
pactVersion = getCheckedOutGitCommitHash()
}
task fortifyScan(type: JavaExec) {
mainClass.set("uk.gov.hmcts.fortifyclient.FortifyClientMainApp")
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
task runAndPublishConsumerPactTests(type: Test) {
logger.lifecycle("Runs pact Tests")
testClassesDirs = sourceSets.testContract.output.classesDirs
classpath = sourceSets.testContract.runtimeClasspath
}
runAndPublishConsumerPactTests.dependsOn pactTask
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
}
}
tasks.pactPublish { dependsOn(test) }
task generateAatEnvFile() {
doFirst {
print 'Generating AAT env var file'
"sh ./generate-aat-env-file.sh".execute()
// Sleep to allow secrets to be fetched:
sleep(20 * 1000)
}
}
run {
if (new Boolean(System.getenv("POINT_TO_AAT"))) {
print 'Exporting AAT env vars'
doFirst {
if (project.file('./.aat-env').exists()) {
project.file('./.aat-env').readLines().each() {
def index = it.indexOf("=")
def key = it.substring(0, index)
def value = it.substring(index + 1)
environment key, value
}
}
}
}
if (debug == 'true') {
jvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005']
}
}
rootProject.tasks.named("processResources") {
dependsOn("generateGitProperties")
}