-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
157 lines (135 loc) · 4.82 KB
/
build.gradle.kts
File metadata and controls
157 lines (135 loc) · 4.82 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
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.23"
id("org.jetbrains.kotlin.plugin.allopen") version "1.9.23"
id("com.google.devtools.ksp") version "1.9.23-1.0.19"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.micronaut.application") version "4.4.0"
id("io.micronaut.test-resources") version "4.4.0"
id("io.micronaut.aot") version "4.4.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
}
group = "city.db"
val kotlinVersion = project.properties["kotlinVersion"]
repositories {
mavenCentral()
}
dependencies {
ksp("io.micronaut.openapi:micronaut-openapi")
ksp("io.micronaut:micronaut-http-validation")
ksp("io.micronaut.serde:micronaut-serde-processor")
ksp("io.micronaut.data:micronaut-data-processor")
implementation("io.micronaut.validation:micronaut-validation")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut.serde:micronaut-serde-jackson")
implementation("com.opencsv:opencsv:5.9")
implementation("io.micronaut.data:micronaut-data-jdbc")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.micronaut.flyway:micronaut-flyway")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
compileOnly("io.micronaut.openapi:micronaut-openapi-annotations")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
runtimeOnly("com.mysql:mysql-connector-j")
runtimeOnly("org.flywaydb:flyway-mysql")
testImplementation("org.testcontainers:mysql:1.18.3")
testImplementation("org.testcontainers:testcontainers")
}
application {
mainClass = "city.db.ApplicationKt"
}
java {
sourceCompatibility = JavaVersion.toVersion("21")
}
graalvmNative.toolchainDetection = false
micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("city.db.*")
}
testResources {
additionalModules.add("jdbc-postgresql")
}
aot {
optimizeServiceLoading = false
convertYamlToJava = false
precomputeOperations = true
cacheEnvironment = true
optimizeClassLoading = true
deduceEnvironment = true
optimizeNetty = true
replaceLogbackXml = true
}
}
graalvmNative {
binaries {
named("main") {
imageName.set("geonames-api")
}
}
}
tasks.named<io.micronaut.gradle.docker.NativeImageDockerfile>("dockerfileNative") {
jdkVersion = "21"
instruction("RUN apk add curl")
instruction("""HEALTHCHECK CMD curl -s localhost:8080/health | grep '"status":"UP"' """)
}
ksp {
arg("micronaut.openapi.project.dir", projectDir.toString())
}
// deployment and docker push to docker hub registry
tasks.register<Exec>("dockerTagLatest") {
group = "release"
dependsOn("dockerBuildNative")
commandLine("docker", "tag", "geonames-api:latest", "beberhardt/geonames-api:latest")
}
tasks.register<Exec>("dockerTagVersion") {
group = "release"
dependsOn("dockerBuildNative")
commandLine("docker", "tag", "geonames-api:latest", "beberhardt/geonames-api:$version")
}
tasks.register<Exec>("dockerPushLatestImage") {
group = "release"
dependsOn("dockerTagLatest")
commandLine("docker", "push", "beberhardt/geonames-api:latest")
}
tasks.register<Exec>("dockerPushVersionedImage") {
group = "release"
dependsOn("dockerTagVersion")
commandLine("docker", "push", "beberhardt/geonames-api:$version")
}
tasks.register("tagAndPushImages") {
group = "release"
dependsOn("dockerPushVersionedImage", "dockerPushLatestImage")
}
tasks.register("incrementVersion") {
group = "release"
doLast {
println(":incrementVersion - Incrementing Version...")
val buildGradleFile = file("gradle.properties")
val lines = buildGradleFile.readLines()
val changedLines =
lines.map {
if (it.startsWith("version=", true)) {
println("current $it")
val versionParts = it.split(".")
val newVersion =
versionParts.mapIndexed { index, part ->
if (index != versionParts.size - 1) {
part
} else {
part.toInt() + 1
}
}
val versionText = newVersion.joinToString(".")
println("new $versionText")
versionText
} else {
it
}
}
buildGradleFile.writeText(changedLines.joinToString("\n"))
}
}