-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
139 lines (121 loc) · 4.14 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
import org.owasp.dependencycheck.gradle.extension.DependencyCheckExtension
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
import kotlin.jvm.optionals.getOrNull
plugins {
base
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.plugin.spring)
alias(libs.plugins.kotlin.plugin.serialization)
alias(libs.plugins.spotless)
alias(libs.plugins.sonarqube)
alias(libs.plugins.dependencycheck)
jacoco
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation(libs.presentation.exchange)
implementation(libs.nimbusds.oauth2.oidc.sdk)
implementation("org.springframework.boot:spring-boot-starter-security")
implementation(libs.bouncy.castle)
implementation(libs.arrow.core)
implementation(libs.arrow.fx.coroutines)
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.webjars:webjars-locator-core")
implementation(libs.swagger.ui)
testImplementation(kotlin("test"))
testImplementation(libs.kotlinx.coroutines.test)
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
}
java {
val javaVersion = getVersionFromCatalog("java")
sourceCompatibility = JavaVersion.toVersion(javaVersion)
}
kotlin {
jvmToolchain {
val javaVersion = getVersionFromCatalog("java")
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
freeCompilerArgs.add("-Xcontext-receivers")
freeCompilerArgs.add("-Xjsr305=strict")
}
}
tasks.test {
finalizedBy(tasks.jacocoTestReport)
}
tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required = true
csv.required = true
html.required = true
}
}
testing {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
}
}
}
jacoco {
toolVersion = libs.versions.jacoco.get()
}
springBoot {
buildInfo()
}
tasks.named<BootBuildImage>("bootBuildImage") {
imageName.set("$group/${project.name}")
publish.set(false)
// get the BP_OCI_* from env, for https://github.com/paketo-buildpacks/image-labels
// get the BP_JVM_* from env, jlink optimisation
environment.set(System.getenv())
val env = environment.get()
docker {
publishRegistry {
env["REGISTRY_URL"]?.let { url = it }
env["REGISTRY_USERNAME"]?.let { username = it }
env["REGISTRY_PASSWORD"]?.let { password = it }
}
env["DOCKER_METADATA_OUTPUT_TAGS"]?.let { tagStr ->
tags = tagStr.split(delimiters = arrayOf("\n", " ")).onEach { println("Tag: $it") }
}
}
}
spotless {
val ktlintVersion = getVersionFromCatalog("ktlintVersion")
kotlin {
ktlint(ktlintVersion)
licenseHeaderFile("FileHeader.txt")
}
kotlinGradle {
ktlint(ktlintVersion)
}
}
fun getVersionFromCatalog(lookup: String): String {
val versionCatalog: VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
return versionCatalog
.findVersion(lookup)
.getOrNull()
?.requiredVersion
?: throw GradleException("Version '$lookup' is not specified in the version catalog")
}
val nvdApiKey: String? = System.getenv("NVD_API_KEY") ?: properties["nvdApiKey"]?.toString()
val dependencyCheckExtension = extensions.findByType(DependencyCheckExtension::class.java)
dependencyCheckExtension?.apply {
formats = mutableListOf("XML", "HTML")
nvd.apiKey = nvdApiKey ?: ""
}