From cd2a40b430802a86217bef48bde57bb2e4e940b7 Mon Sep 17 00:00:00 2001 From: fcaps Date: Fri, 8 Dec 2023 01:06:27 +0100 Subject: [PATCH] adding native image --- .github/workflows/native-build.yaml | 31 +++++++++++++++++++++++++++++ build.gradle.kts | 4 ++++ kia-cli/build.gradle.kts | 10 ++++++++++ 3 files changed, 45 insertions(+) create mode 100644 .github/workflows/native-build.yaml diff --git a/.github/workflows/native-build.yaml b/.github/workflows/native-build.yaml new file mode 100644 index 0000000..da7b11c --- /dev/null +++ b/.github/workflows/native-build.yaml @@ -0,0 +1,31 @@ +name: GraalVM Native Image builds +on: [push] +jobs: + build: + name: ICE on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest] + steps: + - uses: actions/checkout@v4 + + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '17' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: 'true' + - name: Log info + run: | + echo "GRAALVM_HOME: $GRAALVM_HOME" + echo "JAVA_HOME: $JAVA_HOME" + java --version + native-image --version + - name: Example step using Gradle plugin # https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html + run: ./gradlew nativeCompile + - name: Upload binary + uses: actions/upload-artifact@v2 + with: + name: kia-cli-${{ matrix.os }} + path: kia-cli* \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index e37dbfa..55aa2ae 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,6 +15,7 @@ subprojects { repositories { mavenCentral() maven { setUrl("https://jitpack.io") } + gradlePluginPortal() } apply(plugin = "com.adarshr.test-logger") @@ -40,4 +41,7 @@ plugins { id("org.jetbrains.kotlin.plugin.allopen") version kotlinVersion apply false id("com.diffplug.spotless") version "6.21.0" apply false id("com.adarshr.test-logger") version "3.2.0" apply false + id("org.graalvm.buildtools.native") version "0.9.28" apply false } + + diff --git a/kia-cli/build.gradle.kts b/kia-cli/build.gradle.kts index 5685928..be30e2e 100644 --- a/kia-cli/build.gradle.kts +++ b/kia-cli/build.gradle.kts @@ -4,6 +4,7 @@ plugins { id("org.jetbrains.kotlin.jvm") id("org.jetbrains.kotlin.kapt") id("com.github.johnrengelman.shadow") version "8.1.1" + id("org.graalvm.buildtools.native") } dependencies { @@ -22,6 +23,15 @@ dependencies { implementation(project(":kia-lib")) } +graalvmNative { + toolchainDetection.set(true) + binaries { + named("main") { + mainClass.set("com.faforever.ice.KiaApplication") + } + } +} + tasks { build { dependsOn(shadowJar)