generated from digitalservicebund/java-application-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle.kts
362 lines (311 loc) · 12.3 KB
/
build.gradle.kts
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
import com.adarshr.gradle.testlogger.theme.ThemeType
import com.github.jk1.license.filter.DependencyFilter
import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.CsvReportRenderer
import com.github.jk1.license.render.ReportRenderer
import io.franzbecker.gradle.lombok.task.DelombokTask
import org.flywaydb.gradle.task.FlywayMigrateTask
plugins {
java
jacoco
id("org.springframework.boot") version "3.3.5"
id("io.spring.dependency-management") version "1.1.6"
id("com.diffplug.spotless") version "6.25.0"
id("org.sonarqube") version "6.0.1.5171"
id("com.github.jk1.dependency-license-report") version "2.9"
id("com.gorylenko.gradle-git-properties") version "2.4.2"
id("com.adarshr.test-logger") version "4.0.0"
id("se.patrikerdes.use-latest-versions") version "0.2.18"
id("com.github.ben-manes.versions") version "0.51.0"
id("io.franzbecker.gradle-lombok") version "5.0.0"
id("org.flywaydb.flyway") version "11.0.1"
id("io.sentry.jvm.gradle") version "4.14.1"
}
group = "de.bund.digitalservice"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_21
repositories {
mavenCentral()
maven {
setUrl("https://plugins.gradle.org/m2/")
}
maven {
url = uri("https://maven.pkg.github.com/digitalservicebund/neuris-juris-xml-export")
credentials {
username = System.getenv("GH_PACKAGES_REPOSITORY_USER")
password = System.getenv("GH_PACKAGES_REPOSITORY_TOKEN")
}
}
// mavenLocal() // for local testing of library when publishing to maven local.
}
sourceSets {
create("migration") {
java.srcDir("src/main/java")
java.include("db/migration/**/*.java")
}
}
jacoco {
toolVersion = "0.8.12"
}
lombok {
version = "1.18.36"
}
springBoot {
buildInfo()
}
testlogger {
theme = ThemeType.MOCHA
}
configurations {
compileOnly {
extendsFrom(annotationProcessor.get())
}
}
spotless {
java {
removeUnusedImports()
googleJavaFormat()
custom("Refuse wildcard imports") {
// Wildcard imports can't be resolved by spotless itself.
// This will require the developer themselves to adhere to best practices.
if (it.contains("\nimport .*\\*;".toRegex())) {
throw AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.")
}
it
}
}
format("misc") {
target(
"**/*.js",
"**/*.json",
"**/*.md",
"**/*.properties",
"**/*.sh",
"**/*.sql",
"**/*.yaml",
"**/*.yml"
)
targetExclude(
"frontend/**",
"**/?/**",
"**/*.sql",
"**/dist/**",
"**/static/**",
"**/gradle.properties",
"**/gradle-wrapper.properties",
"**/jaxb.properties",
"**/sentry-debug-meta.properties"
)
// spotless:off
prettier(
mapOf(
"prettier" to "3.3.3",
"prettier-plugin-properties" to "0.3.0",
"prettier-plugin-sh" to "0.14.0",
"prettier-plugin-sql" to "0.18.0"
)
).config(
mapOf(
"keySeparator" to "=", // for prettier-plugin-properties
"language" to "postgresql" // for prettier-plugin-sql
)
)
// spotless:on
}
}
licenseReport {
allowedLicensesFile = File("$projectDir/../allowed-licenses.json")
renderers = arrayOf<ReportRenderer>(CsvReportRenderer("backend-licence-report.csv"))
filters = arrayOf<DependencyFilter>(LicenseBundleNormalizer())
}
sonar {
properties {
property("sonar.projectKey", "digitalservicebund_ris-backend-service")
property("sonar.organization", "digitalservicebund")
property("sonar.host.url", "https://sonarcloud.io")
property(
"sonar.coverage.exclusions",
"**/config/**,**/S3AsyncMockClient.java,**/Application.java"
)
}
}
dependencies {
val testContainersVersion = "1.20.4"
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-data-redis")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-autoconfigure")
implementation("org.springframework.session:spring-session-data-redis")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.security:spring-security-oauth2-resource-server:6.4.1")
implementation("org.springframework.cloud:spring-cloud-starter-kubernetes-client-config:3.1.4")
// CVE-2024-26308
implementation("org.apache.commons:commons-compress:1.27.1")
// CVE-2022-3171
implementation("com.google.protobuf:protobuf-java:4.29.1")
// CVE-2023-52428 in spring-boot-starter-oauth2-client:3.2.3
implementation("com.nimbusds:nimbus-jose-jwt:9.47")
// CVE-2023-31582
implementation("org.bitbucket.b_c:jose4j:0.9.6")
implementation("org.postgresql:postgresql:42.7.4")
implementation("com.sendinblue:sib-api-v3-sdk:7.0.0")
// CVE-2022-4244
implementation("org.codehaus.plexus:plexus-utils:4.0.2")
implementation(platform("software.amazon.awssdk:bom:2.29.29"))
implementation("software.amazon.awssdk:netty-nio-client")
implementation("software.amazon.awssdk:s3")
implementation("org.docx4j:docx4j-JAXB-ReferenceImpl:11.5.1")
implementation("org.freehep:freehep-graphicsio-emf:2.4")
// caselaw tranformation to LDML for the communication with the portal
implementation("org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.4")
implementation("net.sf.saxon:Saxon-HE:12.5")
implementation("jakarta.mail:jakarta.mail-api:2.1.3")
implementation("org.eclipse.angus:angus-mail:2.0.3")
implementation("com.icegreen:greenmail:2.1.2")
// package served by private repo, requires authentication:
implementation("de.bund.digitalservice:neuris-juris-xml-export:0.10.22") {
exclude(group = "org.slf4j", module = "slf4j-simple")
}
// for local development:
// implementation(files("../../neuris-juris-xml-export/build/libs/neuris-juris-xml-export-0.10.22.jar"))
// or with local gradle project (look also into settings.gradle.kts)
// implementation(project(":exporter"))
implementation("de.bund.digitalservice:neuris-caselaw-migration-schema:0.0.32")
// for local development:
// implementation(files("../../ris-data-migration/schema/build/libs/schema-0.0.32.jar"))
implementation("com.fasterxml.jackson.core:jackson-core:2.18.2")
implementation("com.fasterxml.jackson.core:jackson-databind:2.18.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.2")
implementation("com.gravity9:json-patch-path:2.0.2")
implementation("io.micrometer:micrometer-registry-prometheus:1.14.1")
implementation("io.micrometer:micrometer-core:1.14.1")
implementation("com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1")
// => CVE-2023-2976
implementation("com.google.guava:guava:33.3.1-jre")
implementation("io.getunleash:unleash-client-java:9.2.6")
implementation("org.apache.commons:commons-text:1.12.0")
implementation("org.jsoup:jsoup:1.18.3")
implementation("net.javacrumbs.shedlock:shedlock-spring:6.0.2")
implementation("net.javacrumbs.shedlock:shedlock-provider-jdbc-template:6.0.2")
val flywayCore = "org.flywaydb:flyway-core:11.0.1"
implementation(flywayCore)
"migrationImplementation"(flywayCore)
runtimeOnly("org.flywaydb:flyway-database-postgresql:11.0.1")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.mockito", module = "mockito-core")
}
testImplementation("org.mockito:mockito-junit-jupiter:5.14.2")
testImplementation("org.mockito:mockito-inline:5.2.0")
testImplementation("io.projectreactor:reactor-test:3.7.0")
testImplementation("org.springframework.security:spring-security-test:6.4.1")
testImplementation("com.tngtech.archunit:archunit-junit5:1.3.0")
testImplementation("org.testcontainers:testcontainers:$testContainersVersion")
testImplementation("org.testcontainers:junit-jupiter:$testContainersVersion")
testImplementation("org.testcontainers:postgresql:$testContainersVersion")
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
developmentOnly("org.springframework.boot:spring-boot-devtools")
}
project.tasks.sonar {
dependsOn("jacocoTestReport")
}
tasks {
register<FlywayMigrateTask>("migrateDatabaseForERD") {
url = System.getenv("DB_URL")
user = System.getenv("DB_USER")
password = System.getenv("DB_PASSWORD")
locations = arrayOf(
"filesystem:src/main/resources/db/migration/", "classpath:db/migration"
)
dependsOn("compileMigrationJava")
}
jar {
enabled = false
}
withType<Test> {
maxParallelForks = Runtime.getRuntime().availableProcessors().div(2)
}
getByName<Test>("test") {
useJUnitPlatform {
excludeTags("integration", "manual")
}
}
task<Test>("integrationTest") {
description = "Runs the integration tests."
group = "verification"
useJUnitPlatform {
includeTags("integration")
excludeTags("manual")
}
// So that running integration test require running unit tests first,
// and we won"t even attempt running integration tests when there are
// failing unit tests.
dependsOn("test")
finalizedBy("jacocoTestReport")
}
check {
dependsOn("integrationTest")
}
jacocoTestReport {
// Jacoco hooks into all tasks of type: Test automatically, but results for each of these
// tasks are kept separately and are not combined out of the box. we want to gather
// coverage of our unit and integration tests as a single report!
executionData.setFrom(
files(
fileTree(project.layout.buildDirectory) {
include("jacoco/*.exec")
},
),
)
dependsOn("integrationTest")
reports {
xml.required.set(true)
html.required.set(true)
}
classDirectories.setFrom(
files(classDirectories.files.map {
fileTree(it) {
exclude("**/config/**")
}
})
)
}
bootBuildImage {
val containerRegistry = System.getenv("CONTAINER_REGISTRY") ?: "ghcr.io"
val containerImageName =
System.getenv("CONTAINER_IMAGE_NAME") ?: "digitalservicebund/${rootProject.name}"
val containerImageVersion = System.getenv("CONTAINER_IMAGE_VERSION") ?: "latest"
imageName.set("$containerRegistry/$containerImageName:$containerImageVersion")
builder.set("paketobuildpacks/builder-jammy-tiny")
publish.set(false)
docker {
publishRegistry {
username.set(System.getenv("CONTAINER_REGISTRY_USER") ?: "")
password.set(System.getenv("CONTAINER_REGISTRY_PASSWORD") ?: "")
url.set("https://$containerRegistry")
}
}
}
val delombok by registering(DelombokTask::class) {
dependsOn(compileJava)
mainClass.set("lombok.launch.Main")
val outputDir by extra { file("${project.layout.buildDirectory}/delombok") }
outputs.dir(outputDir)
sourceSets["main"].java.srcDirs.forEach {
inputs.dir(it)
args(it, "-d", outputDir)
}
doFirst {
outputDir.delete()
}
}
javadoc {
dependsOn(delombok)
val outputDir: File by delombok.get().extra
source = fileTree(outputDir)
isFailOnError = false
}
}