Skip to content

Commit 0cbfc5a

Browse files
committed
chore: kotlin 1.9.20-Beta, Helidon 4.0, GraalVM config fixes
1 parent c31af20 commit 0cbfc5a

File tree

16 files changed

+545
-52
lines changed

16 files changed

+545
-52
lines changed

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ plugins { plugins.graalvm }
22

33
dependencies {
44
implementation(platform(libs.ktor.bom))
5-
implementation(platform(libs.helidon.nima.bom))
6-
implementation(libs.helidon.nima.webserver)
7-
implementation(libs.helidon.nima.static)
8-
implementation(libs.helidon.nima.service)
5+
implementation(platform(libs.helidon.bom))
6+
implementation(libs.helidon.webserver)
7+
implementation(libs.helidon.static)
8+
implementation(libs.helidon.service)
99
implementation(libs.ajalt.clikt)
1010
implementation(libs.ajalt.mordant)
1111
implementation(libs.ajalt.colormath)

gradle/build-logic/common-plugins/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ tasks {
2727
kotlin {
2828
sourceSets.all {
2929
languageSettings.apply {
30-
progressiveMode = true
3130
optIn("kotlin.ExperimentalStdlibApi")
3231
optIn("kotlin.io.path.ExperimentalPathApi")
3332
optIn("kotlin.time.ExperimentalTime")

gradle/build-logic/common-plugins/src/main/kotlin/plugins/common.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ tasks {
153153

154154
filteringCharset = "UTF-8"
155155
from(project.projectDir.resolve("src/main/templates"))
156-
into(project.buildDir.resolve("generated-sources/templates/kotlin/main"))
156+
into(project.layout.buildDirectory.dir("generated-sources/templates/kotlin/main"))
157157
exclude { it.name.startsWith("jte") }
158158
expand(props)
159159

gradle/build-logic/common-plugins/src/main/kotlin/plugins/graalvm.gradle.kts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ graalvmNative {
105105
// https://www.graalvm.org/dashboard/?ojr=help%3Btopic%3Dgetting-started.md
106106
}
107107

108-
// resources { autodetect() }
108+
resources {
109+
autodetection {
110+
enabled = true
111+
restrictToProjectDependencies = true
112+
}
113+
}
114+
109115
jvmArgs = listOf("--add-modules=$addModules")
110116
systemProperties = mapOf("java.awt.headless" to "false")
111117
javaLauncher = javaToolchains.launcherFor { configureJvmToolchain() }
@@ -117,7 +123,7 @@ graalvmNative {
117123
enabled = true
118124
metadataCopy {
119125
inputTaskNames.add("run") // Tasks previously executed with the agent attached (test).
120-
outputDirectories.add("src/main/resources/META-INF/native-image/playground")
126+
outputDirectories.add("src/main/resources/META-INF/native-image")
121127
mergeWithExisting = true
122128
}
123129
}

gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.mpp.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply(plugin = "org.jetbrains.kotlin.multiplatform")
2626
val kotlinMultiplatform = extensions.getByType<KotlinMultiplatformExtension>()
2727

2828
kotlinMultiplatform.apply {
29-
targetHierarchy.default()
29+
applyDefaultHierarchyTemplate()
3030

3131
jvmToolchain { configureJvmToolchain() }
3232

@@ -81,7 +81,7 @@ kotlinMultiplatform.apply {
8181
// Disable wasm by default as some of the common dependencies are not compatible with wasm.
8282
if (project.hasProperty("experimental")) {
8383

84-
wasm {
84+
wasmJs {
8585
binaries.executable()
8686
browser {
8787
commonWebpackConfig(

gradle/libs.versions.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
java = "21"
3-
kotlin = "1.9.10"
3+
kotlin = "1.9.20-Beta"
44
kotlin-ksp = "1.9.10-1.0.13"
55
kotlin-jvmtarget = "20"
66
kotlin-dsl-jvmtarget = "17"
@@ -36,7 +36,7 @@ ajalt-clikt = "4.2.0"
3636
ajalt-mordant = "2.1.0"
3737
ajalt-colormath = "3.3.2"
3838
dokka = "1.9.0"
39-
helidon-nima = "4.0.0-M1"
39+
helidon = "4.0.0-M2"
4040
jgit = "6.6.0.202305301015-r"
4141
jte = "3.1.0"
4242
junit = "5.10.0"
@@ -174,12 +174,12 @@ koin-slf4j = { module = "io.insert-koin:koin-logger-slf4j"
174174
koin-test = { module = "io.insert-koin:koin-test" , version.ref = "koin"}
175175
koin-test-junit5 = { module = "io.insert-koin:koin-test-junit5" , version.ref = "koin"}
176176

177-
helidon-nima-bom = { module = "io.helidon.nima:helidon-nima-project" , version.ref = "helidon-nima"}
178-
helidon-nima-webserver = { module = "io.helidon.nima.webserver:helidon-nima-webserver" , version.ref = "helidon-nima"}
179-
helidon-nima-static = { module = "io.helidon.nima.webserver:helidon-nima-webserver-static-content" , version.ref = "helidon-nima"}
180-
helidon-nima-webclient = { module = "io.helidon.nima.webclient:helidon-nima-webclient" , version.ref = "helidon-nima"}
181-
helidon-nima-service = { module = "io.helidon.nima.service-common:helidon-nima-service-common" , version.ref = "helidon-nima"}
182-
helidon-config-yaml = { module = "io.helidon.config:helidon-config-yaml" , version.ref = "helidon-nima"}
177+
helidon-bom = { module = "io.helidon:helidon-bom" , version.ref = "helidon"}
178+
helidon-webserver = { module = "io.helidon.webserver:helidon-webserver" , version.ref = "helidon"}
179+
helidon-service = { module = "io.helidon.webserver:helidon-webserver-service-common" , version.ref = "helidon"}
180+
helidon-static = { module = "io.helidon.webserver:helidon-webserver-static-content" , version.ref = "helidon"}
181+
helidon-webclient = { module = "io.helidon.webclient:helidon-webclient" , version.ref = "helidon"}
182+
helidon-config-yaml = { module = "io.helidon.config:helidon-config-yaml" , version.ref = "helidon"}
183183

184184
ajalt-clikt = { module = "com.github.ajalt.clikt:clikt" , version.ref = "ajalt-clikt"}
185185
ajalt-mordant = { module = "com.github.ajalt.mordant:mordant" , version.ref = "ajalt-mordant"}

src/main/kotlin/dev/suresh/Main.kt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import com.sun.management.OperatingSystemMXBean
44
import dev.suresh.config.BuildEnv
55
import dev.suresh.model.Creds
66
import dev.suresh.model.Secret
7-
import io.helidon.common.http.Http
8-
import io.helidon.common.http.Http.Header
9-
import io.helidon.common.http.NotFoundException
10-
import io.helidon.nima.webserver.WebServer
11-
import io.helidon.nima.webserver.http.HttpRouting
12-
import io.helidon.nima.webserver.http.ServerRequest
13-
import io.helidon.nima.webserver.http.ServerResponse
14-
import io.helidon.nima.webserver.staticcontent.StaticContentService
7+
import io.helidon.http.Http.*
8+
import io.helidon.http.NotFoundException
9+
import io.helidon.webserver.WebServer
10+
import io.helidon.webserver.http.HttpRouting
11+
import io.helidon.webserver.http.ServerRequest
12+
import io.helidon.webserver.http.ServerResponse
13+
import io.helidon.webserver.staticcontent.StaticContentService
1514
import io.ktor.client.*
1615
import io.ktor.client.engine.cio.*
1716
import io.ktor.client.plugins.websocket.*
@@ -119,8 +118,8 @@ val rsClient by lazy {
119118

120119
private fun String.newInstance() = Class.forName(this).getConstructor().newInstance()
121120

122-
val SERVER_HEADER = Header.createCached(Header.SERVER, "Nima")
123-
val UI_REDIRECT = Header.createCached(Header.LOCATION, "/")
121+
val SERVER_HEADER = Headers.createCached(HeaderNames.SERVER, "Nima")
122+
val UI_REDIRECT = Headers.createCached(HeaderNames.LOCATION, "/")
124123

125124
fun routes(rules: HttpRouting.Builder) {
126125
rules
@@ -148,8 +147,8 @@ fun root(req: ServerRequest, res: ServerResponse) {
148147
fun error(req: ServerRequest, res: ServerResponse, ex: Throwable) {
149148
println("ERROR: ${req.path().path()} - ${ex.message}")
150149
when (ex) {
151-
is NotFoundException -> res.status(Http.Status.NOT_FOUND_404)
152-
else -> res.status(Http.Status.INTERNAL_SERVER_ERROR_500)
150+
is NotFoundException -> res.status(Status.NOT_FOUND_404)
151+
else -> res.status(Status.INTERNAL_SERVER_ERROR_500)
153152
}
154153
res.send()
155154
}
@@ -160,7 +159,7 @@ fun shutdown(req: ServerRequest, res: ServerResponse) {
160159
}
161160

162161
fun redirect(req: ServerRequest, res: ServerResponse) {
163-
res.status(Http.Status.MOVED_PERMANENTLY_301)
162+
res.status(Status.MOVED_PERMANENTLY_301)
164163
res.headers().set(UI_REDIRECT)
165164
res.send()
166165
}
@@ -295,27 +294,28 @@ fun summary(args: List<String>) = buildString {
295294
appendLine(ex?.message)
296295
// Host info is not available on native image
297296
if (ImageInfo.isExecutable().not()) {
298-
check(ex?.message?.contains("localhost:12345") == true)
297+
println(ex?.message)
298+
check(ex?.message?.contains("localhost/127.0.0.1:12345") == true)
299299
}
300300

301301
appendLine(
302302
"""
303-
+---------Summary-------+
304-
| Processes : ${ps.size.fmt}|
305-
| Dns Addresses : ${dns.size.fmt}|
306-
| Trust Stores : ${caCerts.size.fmt}|
307-
| TimeZones : ${tz.size.fmt}|
308-
| CharSets : ${cs.size.fmt}|
309-
| Locales : ${locales.size.fmt}|
310-
| Countries : ${countries.size.fmt}|
311-
| Languages : ${languages.size.fmt}|
312-
| Currencies : ${currencies.size.fmt}|
313-
| Env Vars : ${env.size.fmt}|
314-
| Sys Props : ${props.size.fmt}|
315-
| Virtual Thread : ${Thread.currentThread().isVirtual} |
316-
| ScopedValue : ${REQ_URI.orElse("n/a")} |
317-
+-----------------------+
318-
"""
303+
+---------Summary-------+
304+
| Processes : ${ps.size.fmt}|
305+
| Dns Addresses : ${dns.size.fmt}|
306+
| Trust Stores : ${caCerts.size.fmt}|
307+
| TimeZones : ${tz.size.fmt}|
308+
| CharSets : ${cs.size.fmt}|
309+
| Locales : ${locales.size.fmt}|
310+
| Countries : ${countries.size.fmt}|
311+
| Languages : ${languages.size.fmt}|
312+
| Currencies : ${currencies.size.fmt}|
313+
| Env Vars : ${env.size.fmt}|
314+
| Sys Props : ${props.size.fmt}|
315+
| Virtual Thread : ${Thread.currentThread().isVirtual} |
316+
| ScopedValue : ${REQ_URI.orElse("n/a")} |
317+
+-----------------------+
318+
"""
319319
.trimIndent(),
320320
)
321321
}
@@ -326,7 +326,7 @@ fun reflect(req: ServerRequest, res: ServerResponse) {
326326
plugins.forEach { println("ServiceLoader Plugin: ${it.call()}") }
327327

328328
println("Redacted: ${Secret("abc")}, ${Creds("user", "pass")}")
329-
val type = req.path().pathParameters().value("type").trim()
329+
val type = req.path().pathParameters()["type"].trim()
330330
val data =
331331
when (type) {
332332
"java" -> "dev.suresh.model.JVersion".newInstance()
@@ -357,8 +357,8 @@ fun rSocket(req: ServerRequest, res: ServerResponse) =
357357
println("Starting new rSocket connection!")
358358
val rSocket: RSocket = rsClient.rSocket("wss://demo.rsocket.io/rsocket")
359359
val stream = rSocket.requestStream(buildPayload { data("""{ "data": "Kotlin rSocket!" }""") })
360-
res.header(Header.CONTENT_TYPE, "text/event-stream")
361-
res.header(Header.CACHE_CONTROL, "no-cache")
360+
res.header(Headers.CONTENT_TYPE_EVENT_STREAM)
361+
res.header(Headers.CACHE_NO_CACHE)
362362
// Chunked transfer encoding will be set if the response length is zero.
363363
// res.header(Header.TRANSFER_ENCODING,"chunked")
364364
// Streaming binary response - res.header(Header.CONTENT_TYPE,"application/octet-stream")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
{
3+
"name":"dev.suresh.MainKt",
4+
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]
5+
},
6+
{
7+
"name":"java.lang.Boolean",
8+
"methods":[{"name":"getBoolean","parameterTypes":["java.lang.String"] }]
9+
},
10+
{
11+
"name":"java.lang.String",
12+
"methods":[{"name":"lastIndexOf","parameterTypes":["int"] }, {"name":"substring","parameterTypes":["int"] }]
13+
},
14+
{
15+
"name":"java.lang.System",
16+
"methods":[{"name":"getProperty","parameterTypes":["java.lang.String"] }, {"name":"setProperty","parameterTypes":["java.lang.String","java.lang.String"] }]
17+
},
18+
{
19+
"name":"java.lang.VersionProps",
20+
"methods":[{"name":"print","parameterTypes":["boolean"] }]
21+
},
22+
{
23+
"name":"sun.management.VMManagementImpl",
24+
"fields":[{"name":"compTimeMonitoringSupport"}, {"name":"currentThreadCpuTimeSupport"}, {"name":"objectMonitorUsageSupport"}, {"name":"otherThreadCpuTimeSupport"}, {"name":"remoteDiagnosticCommandsSupport"}, {"name":"synchronizerUsageSupport"}, {"name":"threadAllocatedMemorySupport"}, {"name":"threadContentionMonitoringSupport"}]
25+
}
26+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"type":"agent-extracted",
4+
"classes":[
5+
]
6+
}
7+
]

0 commit comments

Comments
 (0)