-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.gradle.kts
276 lines (230 loc) · 10.1 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
// SPDX-FileCopyrightText: 2017-2020 City of Espoo
//
// SPDX-License-Identifier: LGPL-2.1-or-later
import java.util.regex.Pattern
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar
buildscript {
repositories { mavenCentral() }
dependencies { classpath(libs.flyway.database.postgresql) }
}
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.allopen)
alias(libs.plugins.kotlin.spring)
alias(libs.plugins.spring.boot)
alias(libs.plugins.flyway)
alias(libs.plugins.versions)
alias(libs.plugins.ktfmt)
alias(libs.plugins.ktlint.gradle)
alias(libs.plugins.owasp)
idea
}
sourceSets {
register("integrationTest") {
compileClasspath += main.get().output + test.get().output
runtimeClasspath += main.get().output + test.get().output
}
}
val integrationTestImplementation: Configuration by
configurations.getting { extendsFrom(configurations.testImplementation.get()) }
val downloadOnly: Configuration by configurations.creating { isTransitive = false }
configurations["integrationTestRuntimeOnly"].extendsFrom(configurations.testRuntimeOnly.get())
idea {
module { testSources = testSources + sourceSets["integrationTest"].kotlin.sourceDirectories }
}
dependencies {
api(platform(project(":evaka-bom")))
implementation(platform(project(":evaka-bom")))
testImplementation(platform(project(":evaka-bom")))
runtimeOnly(platform(project(":evaka-bom")))
integrationTestImplementation(platform(project(":evaka-bom")))
// Kotlin + core
api(kotlin("stdlib"))
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit5"))
integrationTestImplementation(kotlin("test"))
integrationTestImplementation(kotlin("test-junit5"))
// Logging
implementation("ch.qos.logback.access:logback-access-tomcat")
implementation("io.github.oshai:kotlin-logging-jvm")
implementation("net.logstash.logback:logstash-logback-encoder")
// Spring
api("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-aop")
implementation("org.springframework.boot:spring-boot-starter-jdbc")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-web-services")
implementation("org.springframework.ws:spring-ws-security") { exclude("org.opensaml") }
implementation("org.springframework.ws:spring-ws-support") {
exclude("org.eclipse.angus", "angus-mail")
}
implementation("org.springframework.boot:spring-boot-devtools")
// Database-related dependencies
implementation("com.zaxxer:HikariCP")
implementation("org.flywaydb:flyway-core")
implementation("org.flywaydb:flyway-database-postgresql")
implementation("org.postgresql:postgresql")
// JDBI
implementation("org.jdbi:jdbi3-core")
implementation("org.jdbi:jdbi3-jackson2")
implementation("org.jdbi:jdbi3-kotlin")
implementation("org.jdbi:jdbi3-postgres")
// Fuel
implementation("com.github.kittinunf.fuel:fuel")
implementation("com.github.kittinunf.fuel:fuel-jackson")
// OkHttp
implementation("com.squareup.okhttp3:okhttp")
// Jackson
implementation("com.fasterxml.jackson.core:jackson-core")
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
runtimeOnly("com.fasterxml.jackson.datatype:jackson-datatype-jdk8")
// AWS SDK
implementation("software.amazon.awssdk:s3")
implementation("software.amazon.awssdk:ssm")
implementation("software.amazon.awssdk:sts")
implementation("software.amazon.awssdk:ses")
// Voltti
implementation(project(":service-lib"))
// Flying Saucer <=>
implementation("org.thymeleaf:thymeleaf")
implementation("org.thymeleaf.extras:thymeleaf-extras-java8time")
implementation("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
implementation("org.xhtmlrenderer:flying-saucer-core")
implementation("org.xhtmlrenderer:flying-saucer-pdf-openpdf")
// Miscellaneous
implementation("com.github.kagkarlsson:db-scheduler")
implementation("com.auth0:java-jwt")
implementation("io.micrometer:micrometer-registry-jmx")
implementation("io.opentelemetry:opentelemetry-api")
implementation("jakarta.annotation:jakarta.annotation-api")
implementation("org.apache.commons:commons-text")
implementation("org.glassfish.jaxb:jaxb-runtime")
implementation("org.bouncycastle:bcprov-jdk18on")
implementation("org.bouncycastle:bcpkix-jdk18on")
implementation("org.apache.tika:tika-core")
implementation("org.apache.commons:commons-imaging")
implementation("org.jsoup:jsoup")
implementation("org.apache.commons:commons-csv")
// JUnit
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("io.kotest:kotest-property")
testImplementation("io.mockk:mockk")
testImplementation("net.bytebuddy:byte-buddy")
testImplementation("net.logstash.logback:logstash-logback-encoder")
testImplementation("org.jetbrains:annotations")
testImplementation("org.mockito:mockito-core")
testImplementation("org.mockito:mockito-junit-jupiter")
testImplementation("org.mockito.kotlin:mockito-kotlin")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.ws:spring-ws-test")
testImplementation("com.networknt:json-schema-validator")
integrationTestImplementation("org.apache.cxf:cxf-rt-frontend-jaxws")
integrationTestImplementation("org.apache.cxf:cxf-rt-transports-http")
integrationTestImplementation("org.apache.cxf:cxf-rt-transports-http-jetty")
integrationTestImplementation("org.apache.cxf:cxf-rt-ws-security") { exclude("org.opensaml") }
implementation(project(":sficlient"))
implementation(project(":vtjclient"))
ktlint(project(":custom-ktlint-rules"))
downloadOnly(libs.dd.java.agent)
}
allOpen { annotation("org.springframework.boot.test.context.TestConfiguration") }
allprojects {
tasks.withType<JavaCompile> {
sourceCompatibility = libs.versions.java.get()
targetCompatibility = libs.versions.java.get()
}
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget = JvmTarget.fromTarget(libs.versions.java.get())
allWarningsAsErrors = true
freeCompilerArgs = listOf("-Xconsistent-data-class-copy-visibility")
}
}
tasks.withType<Test> {
useJUnitPlatform()
filter { isFailOnNoMatchingTests = false }
}
tasks.register("resolveDependencies") {
description = "Resolves all dependencies"
doLast {
configurations
.matching {
it.isCanBeResolved &&
// ignore configurations that fetch sources (e.g. Java source code)
!it.name.endsWith("dependencySources", ignoreCase = true)
}
.map {
val files = it.resolve()
it.name to files.size
}
.groupBy({ (_, count) -> count }) { (name, _) -> name }
.forEach { (count, names) ->
@Suppress("ktlint:evaka:no-println")
println(
"Resolved $count dependency files for configurations: ${names.joinToString(", ")}"
)
}
}
}
}
tasks.getByName<Jar>("jar") { archiveClassifier.set("") }
tasks.getByName<BootJar>("bootJar") { archiveClassifier.set("boot") }
tasks {
test { systemProperty("spring.profiles.active", "test") }
register("integrationTest", Test::class) {
useJUnitPlatform()
group = "verification"
systemProperty("spring.profiles.active", "integration-test")
testClassesDirs = sourceSets["integrationTest"].output.classesDirs
classpath = sourceSets["integrationTest"].runtimeClasspath
shouldRunAfter("test")
outputs.upToDateWhen { false }
}
bootRun {
mainClass.set("fi.espoo.evaka.MainKt")
// If you want to develop against VTJ, add vtj-dev here
systemProperty("spring.profiles.active", "local")
}
register("bootRunTest", org.springframework.boot.gradle.tasks.run.BootRun::class) {
mainClass.set("fi.espoo.evaka.MainKt")
classpath = sourceSets["main"].runtimeClasspath
systemProperty("spring.profiles.active", "local")
systemProperty("evaka.database.url", "jdbc:postgresql://localhost:5432/evaka_it")
systemProperty("evaka.database.username", "evaka_it")
systemProperty("evaka.database.password", "evaka_it")
}
register("generateVapidKey", JavaExec::class) {
description = "Generate VAPID key for use with push notifications"
mainClass.set("fi.espoo.evaka.webpush.VapidKeyGeneratorKt")
classpath = sourceSets["test"].runtimeClasspath
}
register("encodePassword", JavaExec::class) {
description = "Encode a password with the default password hash algorithm"
mainClass.set("fi.espoo.evaka.shared.auth.PasswordHasherCliKt")
classpath = sourceSets["test"].runtimeClasspath
}
register("copyDownloadOnlyDeps", Copy::class) {
from(downloadOnly)
into(layout.buildDirectory.dir("download-only"))
// remove version numbers from jar filenames
rename(Pattern.compile("-([0-9]+[.]?)+.jar"), ".jar")
}
dependencyCheck {
failBuildOnCVSS = 0.0f
analyzers.apply {
assemblyEnabled = false
nodeAuditEnabled = false
nodeEnabled = false
nuspecEnabled = false
}
nvd.apply { apiKey = System.getenv("NVD_API_KEY") }
suppressionFile = "$projectDir/owasp-suppressions.xml"
}
}
ktfmt { kotlinLangStyle() }
ktlint { version.set(libs.versions.ktlint.asProvider().get()) }