Skip to content

Commit

Permalink
Experimenting with GraalVM
Browse files Browse the repository at this point in the history
  • Loading branch information
3arthqu4ke committed Jan 21, 2025
1 parent 85f2976 commit 2441e10
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 12 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/graal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Graal Native Image

on:
workflow_dispatch:
push:
pull_request:
types: [opened, reopened]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '23'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Output Graal Info
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: |
./gradlew -Phmc_graal_build=true headlessmc-launcher:nativeCompile
- name: List files
run: ls headlessmc-launcher/build/native/nativeCompile

- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: HeadlessMc Native image files
path: |
./headlessmc-launcher/build/native/nativeCompile/*
17 changes: 11 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ allprojects {
}
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

compileJava {
if (JavaVersion.current().isJava9Compatible()) {
options.compilerArgs.addAll(['--release', '8'])
if (rootProject.hmc_graal_build) {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
} else {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

compileJava {
if (JavaVersion.current().isJava9Compatible()) {
options.compilerArgs.addAll(['--release', '8'])
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ project_version=2.4.1
org.gradle.jvmargs=-Xmx2048m
# set to true if you want to run the headlessmc-launcher-wrapper integration tests
hmc_integration_test_enabled=false
# set to true if you want to build a graalvm image of the headlessmc-launcher
hmc_graal_build=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 2 additions & 1 deletion headlessmc-launcher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
plugins {
id 'application'
id 'org.graalvm.buildtools.native' version '0.10.4'
}

def MAIN_CLASS = 'me.earth.headlessmc.launcher.Main'
application {
mainClass = MAIN_CLASS
mainClass.set(MAIN_CLASS)
}

run {
Expand Down
10 changes: 6 additions & 4 deletions headlessmc-modlauncher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
sourceSets {
java9stub
main {
compileClasspath += java9stub.compileClasspath + java9stub.output
if (!JavaVersion.current().isJava9Compatible()) {
sourceSets {
java9stub
main {
compileClasspath += java9stub.compileClasspath + java9stub.output
}
}
}

Expand Down

0 comments on commit 2441e10

Please sign in to comment.