Hey! I am trying to get Ktor and Exposed to work w...
# server
m
Hey! I am trying to get Ktor and Exposed to work with GraalVM. Has anyone had any success with this?
c
Hey! https://dontasktoask.com/ People browsing this channel are often quite busy, so open-ended questions are unlikely to get an answer. If you want to get someone's attention, describe exactly what your problem is.
s
Try not to cross-post the same question in many channels. It makes information be split when different people will only see the answers to one of the two questions. https://kotlinlang.slack.com/archives/C0CG7E0A1/p1717482898133479 You also didn't add there if you've tried doing it already and you didn't manage to. Or if you're just curious and didn't try it out yourself at all yet
a
I think the most straightforward way to build the image by collecting the metadata via the tracing agent: https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/ Run the java app with the VM option for tracing agent, excecise it so that all the paths in the code are executed, then use the configuration file to build the native image
Here's an example "hello world". Didn't even have to use the tracing agent but used the GraalVM Gradle plugin with some extra options to compile the project with Netty. https://github.com/antonarhipov/ktor-native-image/
🙌 1
Please note that if you add more dependencies to the project, you will need to add it's metadata (if the library doesn't include it) either by using the tracing agent, or by adding more keys to the compilation config in build.gradle.kts file
j
Nice example, it would be great if Ktor libraries included their necessary metadata to ease the native image generation. Do you know if they have plans to add
native-image.properties
in their jars?
a
Yes. That's a work in progress
j
Cool