From 7a1c718270c81f38f725770081c261b28f316dc0 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Wed, 25 Dec 2024 17:20:41 +0100 Subject: [PATCH] Add GraalVM native-image --- build.gradle.kts | 2 +- testapp/build.gradle.kts | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index bc92e15..09c810f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -202,7 +202,7 @@ allprojects { // Configuration moduleName = rootProject.name - moduleVersion = "v" + rootProject.version as String + moduleVersion = "v${this@allprojects.version as String}" failOnWarning = true suppressObviousFunctions = true suppressInheritedMembers = true diff --git a/testapp/build.gradle.kts b/testapp/build.gradle.kts index ddbc122..c7d2c92 100644 --- a/testapp/build.gradle.kts +++ b/testapp/build.gradle.kts @@ -20,6 +20,7 @@ // Plugins plugins { id("application") + id("org.mikeneck.graalvm-native-image") version("v1.4.0") } // Dependencies @@ -75,3 +76,40 @@ application { add("-Djansi.mode=force") } } + +// GraalVM native-image +// -> Configure +nativeImage { + outputs.upToDateWhen { true } + + // for some reason using Gradle properties does not work + graalVmHome = System.getProperty("graalHome", System.getProperty("java.home")) + executableName = "sosengine-testapp" + outputDirectory = file("build/bin") + buildType { build -> + build.executable { + main = "de.staropensource.engine.testapp.Main" + } + } + + arguments { + add("-H:+UnlockExperimentalVMOptions") + add("--color=always") + add("-march=native") + add("-O3") + add("--no-fallback") + add("--report-unsupported-elements-at-runtime") + add("--enable-http") + add("--enable-https") + add("-H:IncludeResources=.*properties\$") + } +} + +// -> Run task +tasks.register("runNativeImage", Exec::class) { + outputs.upToDateWhen { false } + dependsOn(tasks.nativeImage) + + args(application.applicationDefaultJvmArgs) + executable("build/bin/sosengine-testapp") +}