-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
179 lines (151 loc) · 5.72 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
179 lines (151 loc) · 5.72 KB
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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import fr.brouillard.oss.gradle.plugins.JGitverPluginExtensionBranchPolicy
import io.ktor.plugin.features.DockerImageRegistry
import org.cyclonedx.Version
val logbackVersion: String by project
val mockkVersion = "1.14.9"
plugins {
kotlin("jvm") version "2.3.0"
kotlin("plugin.serialization") version "2.3.0"
id("io.ktor.plugin") version "3.4.0"
id("fr.brouillard.oss.gradle.jgitver") version "0.9.1"
id("com.diffplug.spotless") version "8.2.1"
id("org.cyclonedx.bom") version "3.1.0"
id("com.github.ben-manes.versions") version "0.53.0"
}
group = "de.ingrid.ingridapi"
application {
mainClass.set("io.ktor.server.netty.EngineMain")
val isDevelopment: Boolean = project.ext.has("development")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
}
kotlin {
jvmToolchain(21)
}
ktor {
docker {
jreVersion.set(JavaVersion.VERSION_21)
val branchName = System.getenv("BRANCH_NAME").orEmpty()
val tagName = System.getenv("TAG_NAME").orEmpty()
val tag =
if (tagName.isNotEmpty() && !tagName.startsWith("RPM-")) {
tagName
} else if (branchName.isNotEmpty()) {
if (branchName == "main") "latest" else branchName.replace("/", "-")
} else {
"???"
}
externalRegistry.set(
DockerImageRegistry.externalRegistry(
providers.environmentVariable("DOCKER_REGISTRY_CREDS_USR"),
providers.environmentVariable("DOCKER_REGISTRY_CREDS_PSW"),
provider { "docker-registry.wemove.com/ingrid-api:$tag" },
),
)
imageTag.set(tag)
}
}
jgitver {
policy(
closureOf<JGitverPluginExtensionBranchPolicy> {
pattern = "([main|develop|support].*)"
transformations = listOf("IGNORE")
},
)
policy(
closureOf<JGitverPluginExtensionBranchPolicy> {
pattern = "(\\d+\\.\\d+\\.\\d+)"
transformations = listOf("IGNORE")
},
)
}
/*spotless {
kotlin {
ktfmt().kotlinlangStyle()
}
}*/
repositories {
mavenCentral()
maven("https://maven.tryformation.com/releases") {
content {
includeGroup("com.jillesvangurp")
}
}
}
configurations.all {
resolutionStrategy {
force("org.slf4j:slf4j-api:2.0.17")
force("ch.qos.logback:logback-classic:$logbackVersion")
force("ch.qos.logback:logback-core:$logbackVersion")
}
}
dependencies {
// ktor
implementation("io.ktor:ktor-server-core-jvm")
implementation("io.ktor:ktor-server-netty-jvm")
implementation("io.ktor:ktor-server-config-yaml")
implementation("io.ktor:ktor-server-cors")
implementation("io.ktor:ktor-server-compression")
implementation("io.ktor:ktor-server-status-pages")
implementation("io.ktor:ktor-server-compression-jvm")
implementation("io.ktor:ktor-server-host-common-jvm")
implementation("io.ktor:ktor-server-status-pages-jvm")
implementation("io.ktor:ktor-server-forwarded-header")
implementation("io.ktor:ktor-server-forwarded-header-jvm")
// support JSON export
implementation("io.ktor:ktor-server-content-negotiation")
implementation("io.ktor:ktor-serialization-kotlinx-json")
// actually useful for tests
implementation("io.ktor:ktor-client-content-negotiation")
// swagger
implementation("io.github.smiley4:ktor-swagger-ui:5.4.0")
implementation("io.github.smiley4:ktor-openapi:5.4.0")
// Admin GUI: server-side HTML via kotlinx.html DSL (no separate template files)
implementation("io.ktor:ktor-server-html-builder")
// OAuth2 / BFF for the admin GUI (Keycloak)
implementation("io.ktor:ktor-server-auth")
implementation("io.ktor:ktor-server-sessions")
implementation("io.ktor:ktor-client-core")
implementation("io.ktor:ktor-client-cio")
implementation("io.ktor:ktor-client-apache5")
// elasticsearch-client
implementation("com.jillesvangurp:search-client:2.8.4")
// dependency injection (Ktor DI)
implementation("io.ktor:ktor-server-di")
// removed Koin dependencies
testImplementation("io.mockk:mockk:$mockkVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
implementation("io.github.oshai:kotlin-logging-jvm:7.0.4")
// tests
testImplementation("io.ktor:ktor-server-tests-jvm:2.3.13")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
// testImplementation("io.ktor:ktor-server-test-host-jvm:2.3.12")
// testImplementation("org.jetbrains.kotlin:kotlin-test")
}
tasks.cyclonedxBom {
// includeConfigs is the list of configuration names to include when generating the BOM (leave empty to include every configuration), regex is supported
// setIncludeConfigs(listOf("runtimeClasspath"))
// skipConfigs is a list of configuration names to exclude when generating the BOM, regex is supported
// setSkipConfigs(listOf("compileClasspath", "testCompileClasspath"))
projectType = org.cyclonedx.model.Component.Type.APPLICATION
schemaVersion = Version.VERSION_15
jsonOutput = file("build/reports/bom.json")
componentVersion = rootProject.version.toString()
}
tasks {
test {
ignoreFailures = true
}
}
// https://github.com/ben-manes/gradle-versions-plugin
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
isNonStable(candidate.version)
}
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}