generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
304 lines (251 loc) · 9.85 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
//This is required as flyway now has a stand alone library for each database rather than being bundled together
buildscript {
dependencies {
classpath("org.flywaydb:flyway-database-postgresql:11.1.1")
}
}
plugins {
id 'application'
id 'checkstyle'
id 'io.spring.dependency-management' version '1.1.7'
id 'jacoco'
id 'org.springframework.boot' version '3.4.1'
id 'org.owasp.dependencycheck' version '10.0.3'
id 'org.sonarqube' version '6.0.1.5171'
id 'pmd'
id 'org.flywaydb.flyway' version '11.1.1'
id 'io.freefair.lombok' version '8.11'
id 'org.jetbrains.kotlin.jvm' version '2.1.0'
}
application {
group = 'uk.gov.hmcts.reform.pip'
mainClass = 'uk.gov.hmcts.reform.pip.data.management.Application'
version = '0.0.1'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
}
sourceSets {
functionalTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/functionalTest/java')
}
resources.srcDir file('src/functionalTest/resources')
}
integrationTest {
java {
compileClasspath += main.output
runtimeClasspath += main.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')
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror"
}
// https://github.com/gradle/gradle/issues/16791
tasks.withType(JavaExec).configureEach {
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
test {
failFast = true
}
task functional(type: Test) {
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
}
task smoke(type: Test) {
description = "Runs Smoke Tests"
testClassesDirs = sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
}
checkstyle {
maxWarnings = 0
toolVersion = '10.21.1'
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
pmd {
toolVersion = "7.9.0"
sourceSets = [sourceSets.main, sourceSets.test, sourceSets.functionalTest, sourceSets.integrationTest, sourceSets.smokeTest]
reportsDir = file("${layout.buildDirectory.get()}/reports/pmd")
ruleSetFiles = files("config/pmd/ruleset.xml")
}
configurations {
functionalTestImplementation.extendsFrom testImplementation
functionalTestRuntimeOnly.extendsFrom runtimeOnly
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom runtimeOnly
smokeTestImplementation.extendsFrom functionalTestImplementation
smokeTestRuntimeOnly.extendsFrom runtimeOnly
all {
exclude group: 'commons-logging', module: 'commons-logging'
}
}
jacoco {
toolVersion = "0.8.12"
}
jacocoTestReport {
executionData(test, integration)
reports {
xml.required = true
csv.required = false
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml"))
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.8
}
}
}
}
flyway {
url = System.getenv('FLYWAY_URL')
user = System.getenv('FLYWAY_USER')
password = System.getenv('FLYWAY_PASSWORD')
baselineOnMigrate = true
baselineVersion = '000'
}
task migratePostgresDatabase(type: org.flywaydb.gradle.task.FlywayMigrateTask) {
baselineOnMigrate = true
if (project.hasProperty("dburl")) {
url = "jdbc:postgresql://${dburl}"
}
}
project.tasks['sonarqube'].dependsOn jacocoTestReport
def sonarExclusions = ["src/main/java/uk/gov/hmcts/reform/pip/data/management/config/AzureBlobConfiguration.java"]
sonarqube {
properties {
property "sonar.projectName", "PIP Data Management"
property "sonar.projectKey", "pip-data-management"
property "sonar.exclusions", sonarExclusions.join(', ')
}
}
// 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
}
}
ext {
reformLoggingVersion = "6.1.7"
log4JVersion = "2.24.3"
}
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-thymeleaf'
implementation group: 'com.azure', name: 'azure-storage-blob', version: '12.29.0'
implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.9.0'
implementation group: 'io.hypersistence', name: 'hypersistence-utils-hibernate-63', version: '3.9.0'
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.7.0'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: reformLoggingVersion
implementation group: 'com.github.hmcts.java-logging', name: 'logging-appinsights', version: reformLoggingVersion
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4JVersion
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: log4JVersion
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.0'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.7.4'
implementation group: 'com.github.hmcts', name: 'pip-data-models', version: '2.2.5'
implementation 'com.networknt:json-schema-validator:1.5.4'
implementation group: 'com.google.guava', name: 'guava', version: '33.4.0-jre'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.4.0'
implementation group: 'com.openhtmltopdf', name: 'openhtmltopdf-pdfbox', version: '1.0.10'
implementation group: 'com.openhtmltopdf', name: 'openhtmltopdf-slf4j', version: '1.0.10'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.azure.spring:spring-cloud-azure-starter-active-directory:5.19.0'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'com.opencsv:opencsv:5.10'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.retry:spring-retry:2.0.11'
// Include Flyway for database migrations
implementation group: 'org.flywaydb', name: 'flyway-core', version: '11.1.1'
implementation group: 'org.flywaydb', name: 'flyway-database-postgresql', version: '11.1.1'
// Force upgrade snakeyaml version for CVE-2022-1471
implementation( group: 'org.yaml', name: 'snakeyaml').version {
strictly("2.0")
}
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
testImplementation "io.zonky.test:embedded-database-spring-test:2.6.0"
testImplementation(platform('org.junit:junit-bom:5.11.4'))
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: 'org.springframework.security', name: 'spring-security-test'
testImplementation group: 'io.github.hakky54', name: 'logcaptor', version: '2.10.1'
testImplementation group: 'org.apiguardian', name: 'apiguardian-api', version: '1.1.2'
testImplementation group: 'com.github.hmcts', name: 'fortify-client', version: '1.4.6', classifier: 'all'
testImplementation group: 'org.jsoup', name: 'jsoup', version: '1.18.3'
testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0'
functionalTestImplementation group: 'io.rest-assured', name: 'rest-assured'
}
task fortifyScan(type: JavaExec) {
mainClass = "uk.gov.hmcts.fortifyclient.FortifyClientMainApp"
classpath += sourceSets.test.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
bootJar {
archiveFileName = "pip-data-management.jar"
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
// Gradle 7.x issue, workaround from: https://github.com/gradle/gradle/issues/17236#issuecomment-894768083
rootProject.tasks.named("processSmokeTestResources") {
duplicatesStrategy = 'include'
}
// Gradle 7.x issue, workaround from: https://github.com/gradle/gradle/issues/17236#issuecomment-894768083
rootProject.tasks.named("processFunctionalTestResources") {
duplicatesStrategy = 'include'
}
rootProject.tasks.named("processIntegrationTestResources") {
duplicatesStrategy = 'include'
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}