Skip to content

Commit

Permalink
feat: graalvm native image for CLI app
Browse files Browse the repository at this point in the history
  • Loading branch information
y9vad9 committed Nov 13, 2024
1 parent de7dcd7 commit 555ae6a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ compose = "1.7.0"
decompose = "3.2.1"
flowmvi = "3.1.0-beta02"
clikt = "5.0.1"
graalvm = "0.10.3"

[libraries]
# kotlinx libraries
Expand Down Expand Up @@ -88,6 +89,9 @@ flowmvi-debugger-client = { module = "pro.respawn.flowmvi:debugger-plugin", vers
flowmvi-essenty = { module = "pro.respawn.flowmvi:essenty", version.ref = "flowmvi" }
flowmvi-essenty-compose = { module = "pro.respawn.flowmvi:essenty-compose", version.ref = "flowmvi" }

# JNA
net-java-jna = { module = "net.java.dev.jna:jna", version.require = "5.8.0" }

[plugins]
# Build Conventions
conventions-multiplatform-core = { id = "multiplatform-convention", version.require = "SNAPSHOT" }
Expand All @@ -113,4 +117,7 @@ gradle-publish = { id = "com.gradle.plugin-publish", version.require = "1.2.1" }

# Jetbrains
jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose" }
jetbrains-compiler-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
jetbrains-compiler-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

# GraalVM
graalvm-native = { id = "org.graalvm.buildtools.native", version.ref = "graalvm" }
33 changes: 33 additions & 0 deletions tooling/generator-cli/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id(libs.plugins.conventions.jvm.core.get().pluginId)
application
alias(libs.plugins.graalvm.native)
}

dependencies {
Expand All @@ -12,4 +14,35 @@ dependencies {
// -- Generators --
implementation(projects.generator.core)
implementation(projects.generator.kotlin)

// -- JNA --
implementation(libs.net.java.jna)
}

application {
applicationName = "rrgcli"
mainClass = "org.timemates.rrpc.generator.cli.MainKt"
}

graalvmNative {
binaries {
named("main") {
mainClass = "org.timemates.rrpc.generator.cli.MainKt"
buildArgs.addAll(
"--initialize-at-build-time=kotlin.DeprecationLevel",
"-H:ReflectionConfigurationFiles=${project.layout.projectDirectory.dir("src/main/resources/META-INF/native-image/reflect-config.json")}",
"-H:ResourceConfigurationFiles=${project.layout.projectDirectory.dir("src/main/resources/META-INF/native-image/resource-config.json")}",
"-H:Name=rrgcli"
)
useFatJar = true
}
named("test") {
buildArgs.addAll(
"--verbose",
"-O0",
"-H:Name=rrgcli",
)
useFatJar = true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"name": "com.github.ajalt.mordant.terminal.terminalinterface.jna.TerminalInterfaceProviderJna",
"allDeclaredConstructors": true
},
{
"name": "com.github.ajalt.mordant.terminal.terminalinterface.ffm.TerminalInterfaceProviderFfm",
"allDeclaredConstructors": true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"resources": [
{
"pattern": "META-INF/services/.*"
}
]
}

0 comments on commit 555ae6a

Please sign in to comment.