Use official graalvm native-image gradle plugin

This commit is contained in:
AsamK 2021-09-12 19:08:47 +02:00
parent cbff7217c1
commit 627a587952
3 changed files with 19 additions and 43 deletions

View file

@ -3,6 +3,7 @@ plugins {
application
eclipse
`check-lib-versions`
id("org.graalvm.buildtools.native") version "0.9.5"
}
version = "0.9.0"
@ -16,6 +17,15 @@ application {
mainClass.set("org.asamk.signal.Main")
}
graalvmNative {
binaries {
this["main"].run {
configurationFileDirectories.from(file("graalvm-config-dir"))
buildArgs.add("--allow-incomplete-classpath")
}
}
}
repositories {
mavenLocal()
mavenCentral()
@ -63,42 +73,3 @@ tasks.withType<JavaExec> {
args = groovy.util.Eval.me(appArgs) as MutableList<String>
}
}
val assembleNativeImage by tasks.registering {
dependsOn("assemble")
var graalVMHome = ""
doFirst {
graalVMHome = System.getenv("GRAALVM_HOME")
?: throw GradleException("Required GRAALVM_HOME environment variable not set.")
}
doLast {
val nativeBinaryOutputPath = "$buildDir/native-image"
val nativeBinaryName = "signal-cli"
mkdir(nativeBinaryOutputPath)
exec {
workingDir = File(".")
commandLine(
"$graalVMHome/bin/native-image",
"-H:Path=$nativeBinaryOutputPath",
"-H:Name=$nativeBinaryName",
"-H:JNIConfigurationFiles=graalvm-config-dir/jni-config.json",
"-H:DynamicProxyConfigurationFiles=graalvm-config-dir/proxy-config.json",
"-H:ResourceConfigurationFiles=graalvm-config-dir/resource-config.json",
"-H:ReflectionConfigurationFiles=graalvm-config-dir/reflect-config.json",
"--no-fallback",
"--allow-incomplete-classpath",
"--report-unsupported-elements-at-runtime",
"--enable-url-protocols=http,https",
"--enable-https",
"--enable-all-security-services",
"-cp",
sourceSets.main.get().runtimeClasspath.asPath,
application.mainClass.get()
)
}
}
}