-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
305 lines (254 loc) · 10.9 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
plugins {
id 'application'
id 'checkstyle'
id 'pmd'
id 'jacoco'
id "io.spring.dependency-management" version "1.1.4"
id 'org.springframework.boot' version '2.7.18'
id 'uk.gov.hmcts.java' version '0.12.43'
id 'com.github.ben-manes.versions' version '0.46.0'
id 'org.sonarqube' version '4.3.0.3225'
id 'org.owasp.dependencycheck' version '10.0.4'
id "com.gorylenko.gradle-git-properties" version "2.4.1"
id "io.freefair.lombok" version "8.1.0"
}
group = 'uk.gov.hmcts.reform'
version = '1.0.0'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << "-Xlint:unchecked" << "-parameters" << "-Xlint:deprecation"
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
test {
failFast = true
useJUnitPlatform()
}
application {
mainClass.set('uk.gov.hmcts.reform.sscs.CaseLoaderApp')
// this is required to force Java running on the Azure Windows Server OS into using
// UTF-8 as the default character set instead of windows-1252 which causes issues
applicationDefaultJvmArgs = ["-Dfile.encoding=UTF-8"]
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir('src/IntegrationTests/java')
}
}
e2e {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir('src/e2e/java')
}
resources {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir('src/e2e/resources')
}
}
}
tasks.register('integration', Test) {
setTestClassesDirs(sourceSets.integrationTest.output.classesDirs)
setClasspath(sourceSets.integrationTest.runtimeClasspath)
}
tasks.register('functionalPreDeploy', Test) {
group = 'Functional Tests'
description = 'Place delta files on the sftp server ready to be consumed when AKS job is created'
setTestClassesDirs(sourceSets.e2e.output.classesDirs)
setClasspath(sourceSets.e2e.runtimeClasspath)
include "uk/gov/hmcts/reform/sscs/functional/predeploy/**"
exclude "uk/gov/hmcts/reform/sscs/functional/postdeploy/**"
}
tasks.register('functionalPostDeploy', Test) {
group = 'Functional Tests'
description = 'Verifies that files from functionPreDeploy step were processed following job creation in AKS'
setTestClassesDirs(sourceSets.e2e.output.classesDirs)
setClasspath(sourceSets.e2e.runtimeClasspath)
include "uk/gov/hmcts/reform/sscs/functional/postdeploy/**"
exclude "uk/gov/hmcts/reform/sscs/functional/predeploy/**"
}
tasks.register('fortifyScan', JavaExec) {
mainClass = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
pmd {
toolVersion = "6.55.0"
ignoreFailures = true
sourceSets = [
sourceSets.main,
sourceSets.test,
sourceSets.integrationTest,
sourceSets.e2e
]
reportsDir = layout.buildDirectory.dir("reports/pmd").get().asFile
ruleSetFiles = files("config/pmd/ruleset.xml")
}
dependencies {
integrationTestImplementation (sourceSets.test.output)
e2eImplementation (sourceSets.test.output)
}
jacoco {
toolVersion = "0.8.8"
}
jacocoTestReport {
executionData(test, integration)
reports {
xml.getRequired().set(true)
csv.getRequired().set(false)
xml.outputLocation = layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml")
}
}
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all {
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { qualifier -> version.toUpperCase().contains(qualifier) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
selection.reject('Release candidate')
}
}
}
}
// 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 7-10 fails the build, anything lower and it doesn't fail the build
failBuildOnCVSS = System.getProperty('dependencyCheck.failBuild') == 'true' ? 7.0 : 11
suppressionFile = 'config/owasp/suppressions.xml'
nvd.validForHours = 4 // on Jenkins we have 24, so if you get more vulnerabilities locally, try to normalize this value with Jenkins
analyzers {
retirejs {
enabled = false
}
ossIndex {
enabled = false
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
// jitpack should be last resort
// see: https://github.com/jitpack/jitpack.io/issues/1939
maven { url 'https://jitpack.io' }
}
tasks.withType(Copy).configureEach { duplicatesStrategy DuplicatesStrategy.WARN }
project.tasks.named('sonarqube') {
dependsOn test, integration, jacocoTestReport
}
check.dependsOn integration
checkstyleMain.shouldRunAfter(compileJava)
test.shouldRunAfter(checkstyleTest)
integration.shouldRunAfter(checkstyleIntegrationTest)
integration.shouldRunAfter(test)
sonarqube {
properties {
property "sonar.projectName", "SSCS - Case loader"
property "sonar.projectKey", "SSCSCL"
property "sonar.coverage.jacoco.xmlReportPaths", layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml")
property "sonar.exclusions", "**/sscs/models/**, **/sscs/exceptions/**, **/sscs/CaseLoaderApp.java, " +
"**/sscs/services/xml/XmlValidator.java, **/sscs/config/CaseLoaderJobConfig.java, " +
"**/sscs/util/MigrationDataEncoderApp.java, **/sscs/services/ccd/CcdCasesSender.java, " +
"**/sscs/services/CaseLoaderService.java"
}
}
configurations {
integrationTestImplementation.extendsFrom(testImplementation )
integrationTestRuntimeOnly.extendsFrom(testRuntimeOnly)
e2eRuntimeOnly.extendsFrom(testRuntimeOnly)
e2eImplementation.extendsFrom(testImplementation )
}
dependencyManagement {
dependencies {
// CVE-2022-1471
dependency group:'org.yaml', name:'snakeyaml', version:'2.0'
//CVE-2023-6378, CVE-2023-6481
dependencySet(group: 'ch.qos.logback', version: '1.2.13') {
entry 'logback-core'
entry 'logback-classic'
}
}
}
def versions = [
jackson : '2.17.2'
]
dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-batch', version: springBoot.class.package.implementationVersion
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBoot.class.package.implementationVersion
testImplementation group: 'org.springframework.batch', name: 'spring-batch-test'
implementation group: 'com.h2database', name: 'h2', version: '2.2.222'
implementation group: 'org.unix4j', name: 'unix4j-command', version: '0.6'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: springBoot.class.package.implementationVersion
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: springBoot.class.package.implementationVersion
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: springBoot.class.package.implementationVersion
implementation group: 'org.springframework', name: 'spring-context-support'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '3.1.9'
implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
implementation group: 'org.springframework.retry', name: 'spring-retry', version: '1.3.4'
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '4.0.3'
implementation group: 'com.github.hmcts', name: 'idam-java-client', version: '2.1.1'
implementation group: 'com.github.hmcts', name: 'ccd-client', version: '4.9.2'
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '7.4'
implementation group: 'com.github.hmcts', name: 'java-logging', version: '6.0.1'
implementation group: 'com.github.hmcts', name: 'sscs-common', version: '5.12.25'
implementation group: 'com.github.mwiede', name: 'jsch', version: '0.2.11'
implementation group: 'org.json', name: 'json', version: '20240303'
implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
implementation group: 'org.elasticsearch', name: 'elasticsearch', version: '7.17.10'
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: versions.jackson
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: versions.jackson
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jackson
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-cbor', version: versions.jackson
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-csv', version: versions.jackson
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: versions.jackson
testImplementation group: 'net.javacrumbs.json-unit', name: 'json-unit-fluent', version: '2.28.0'
testImplementation group: 'net.javacrumbs.json-unit', name: 'json-unit', version: '2.28.0'
testImplementation group: 'io.rest-assured', name: 'rest-assured'
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.2.2', classifier: 'all', {
exclude group: 'commons-io', module: 'commons-io'
}
implementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
integrationTestImplementation group: 'commons-io', name: 'commons-io', version: '2.11.0'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testImplementation group: 'pl.pragmatists', name: 'JUnitParams', version: '1.1.1'
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '5.10.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.10.0'
testImplementation group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.10.0'
runtimeOnly group: 'org.springframework.boot', name: 'spring-boot-properties-migrator'
}
bootJar {
getArchiveFileName().set(provider {
'sscs-case-loader.jar'
})
manifest {
attributes('Implementation-Title': project.name.toString())
attributes('Implementation-Version': project.version.toString())
}
}
run {
def debug = System.getProperty("debug")
if (debug == 'true') {
jvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005']
}
}