Add GraalVM native-image tasks

This commit is contained in:
JeremyStar™ 2024-07-08 15:40:11 +02:00
parent 867304b568
commit 0e28d746bd
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 68 additions and 4 deletions

View file

@ -1,6 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="RunManager"> <component name="RunManager">
<configuration name="Build test application (native)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="testapp:nativeImage" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Build test application" type="GradleRunConfiguration" factoryName="Gradle"> <configuration name="Build test application" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings> <ExternalSystemSettings>
<option name="executionName" /> <option name="executionName" />
@ -68,6 +90,28 @@
<RunAsTest>false</RunAsTest> <RunAsTest>false</RunAsTest>
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="Run test application (native)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="testapp:runNativeimage" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<configuration name="Run test application" type="GradleRunConfiguration" factoryName="Gradle"> <configuration name="Run test application" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings> <ExternalSystemSettings>
<option name="executionName" /> <option name="executionName" />
@ -79,8 +123,7 @@
</option> </option>
<option name="taskNames"> <option name="taskNames">
<list> <list>
<option value="shadowJar" /> <option value="testapp:runShadow" />
<option value="testapp:run" />
</list> </list>
</option> </option>
<option name="vmOptions" /> <option name="vmOptions" />
@ -114,11 +157,13 @@
<method v="2" /> <method v="2" />
</configuration> </configuration>
<list> <list>
<item itemvalue="Gradle.Build test application (native)" />
<item itemvalue="Gradle.Run test application (native)" />
<item itemvalue="Gradle.Build test application" /> <item itemvalue="Gradle.Build test application" />
<item itemvalue="Gradle.Clean" />
<item itemvalue="Gradle.Generate Javadoc" />
<item itemvalue="Gradle.Run test application" /> <item itemvalue="Gradle.Run test application" />
<item itemvalue="Gradle.Run tests" /> <item itemvalue="Gradle.Run tests" />
<item itemvalue="Gradle.Generate Javadoc" />
<item itemvalue="Gradle.Clean" />
</list> </list>
</component> </component>
</project> </project>

View file

@ -22,6 +22,7 @@ plugins {
id "application" id "application"
id("io.freefair.lombok") version("${pluginLombok}") id("io.freefair.lombok") version("${pluginLombok}")
id("io.github.goooler.shadow") version("${pluginShadow}") id("io.github.goooler.shadow") version("${pluginShadow}")
id('org.mikeneck.graalvm-native-image') version('v1.4.0')
} }
dependencies { dependencies {
@ -73,3 +74,21 @@ application {
"-Djansi.mode=force", "-Djansi.mode=force",
] ]
} }
nativeImage {
graalVmHome = project.hasProperty("graalHome") ? project.property("graalHome") as String : System.getProperty("java.home")
mainClass = "de.staropensource.sosengine.testapp.Main"
executableName = "sosengine-testapp"
outputDirectory = file("build/bin")
arguments {
"--no-fallback"
"--enable-all-security-services"
"--report-unsupported-elements-at-runtime"
}
}
tasks.register('runNativeimage', Exec) {
dependsOn(nativeImage)
executable("build/bin/sosengine-testapp")
args = application.applicationDefaultJvmArgs
}