-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
95 lines (81 loc) · 3.05 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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.aot.ProcessAot
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
id("org.openapi.generator")
id("org.graalvm.buildtools.native")
kotlin("jvm")
kotlin("plugin.spring")
kotlin("plugin.jpa")
}
repositories {
mavenCentral()
}
val dockerRepository: String by project
dependencies {
implementation(project(":common-model"))
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.flywaydb:flyway-database-postgresql")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
// `implementation` is needed only to handle PSQLException in the exception handler. if that is not necessary, the dependency should be `runtimeOnly`
implementation("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.add("-Xjsr305=strict")
}
}
springBoot {
mainClass.set("com.romankudryashov.eventdrivenarchitecture.bookservice.BookServiceApplicationKt")
}
tasks.withType<KotlinCompile> {
dependsOn(tasks.openApiGenerate)
}
tasks.withType<ProcessAot> {
args = mutableListOf("--spring.profiles.active=test")
}
tasks.withType<BootBuildImage> {
buildpacks = setOf("gcr.io/paketo-buildpacks/java-native-image", "gcr.io/paketo-buildpacks/health-checker")
environment = mapOf(
"BP_HEALTH_CHECKER_ENABLED" to "true",
"THC_PATH" to "/actuator/health"
)
imageName = "$dockerRepository:${project.name}"
}
tasks.withType<Test> {
useJUnitPlatform()
}
val openApiPackage = "com.romankudryashov.eventdrivenarchitecture.bookservice.api"
// TODO: haven't found settings not to produce main class and build files. so it is needed to explicitly specify main class above
openApiGenerate {
generatorName.set("kotlin-spring")
inputSpec.set("$projectDir/src/main/resources/openapi/api.yaml")
outputDir.set("$projectDir/build/generated/openapi")
invokerPackage.set(openApiPackage)
apiPackage.set("$openApiPackage.controller")
modelPackage.set("$openApiPackage.model")
configOptions.set(
mapOf(
"delegatePattern" to true.toString(),
"documentationProvider" to "none",
"enumPropertyNaming" to "PascalCase",
"exceptionHandler" to false.toString(),
"gradleBuildFile" to false.toString(),
"useSpringBoot3" to true.toString(),
)
)
}
sourceSets {
main {
kotlin.srcDir(openApiGenerate.outputDir)
}
}