Add GraalVM native-image

This commit is contained in:
JeremyStar™ 2024-12-25 17:20:41 +01:00
parent 11e501a7c4
commit 7a1c718270
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 39 additions and 1 deletions

View file

@ -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

View file

@ -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")
}