Skip to content

Commit

Permalink
cli: Add Native Image build
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzleutgeb committed Dec 20, 2021
1 parent d42818a commit ba5c7d3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,29 @@ jobs:
- uses: codecov/codecov-action@v1
if: matrix.os == env.MAIN_OS && matrix.java == env.MAIN_JAVA
continue-on-error: true
native-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Set up Graal
run: |
mkdir graalvm
wget -qO- 'https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.3.0/graalvm-ce-java17-linux-amd64-21.3.0.tar.gz' | tar xzf - --strip-components=1 -C graalvm
echo "${PWD}/graalvm/bin" >> $GITHUB_PATH
echo "JAVA_HOME=${PWD}/graalvm" >> $GITHUB_ENV
- run: sudo apt-get install -y build-essential libz-dev zlib1g-dev
- run: |
echo $LD_LIBRARY_PATH
sudo ldconfig
- run: gu install native-image
- uses: gradle/gradle-build-action@v2
with:
arguments: build --stacktrace alpha-cli-app:nativeImage -x test
- run: ./alpha-cli-app/build/native-image/alpha --help
- uses: actions/upload-artifact@v2
with:
name: alpha
path: alpha-cli-app/build/native-image/alpha
19 changes: 19 additions & 0 deletions alpha-cli-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id("alpha.java-application-conventions")
id("com.github.johnrengelman.shadow") version "7.1.1"
id("org.mikeneck.graalvm-native-image") version "1.4.1"
}

dependencies {
Expand Down Expand Up @@ -71,3 +73,20 @@ tasks.create<Jar>("bundledJar") {
tasks.test {
useJUnitPlatform()
}

tasks.shadowJar {
archiveClassifier.set("shadow")
}

tasks.nativeImage {
mainClass = main
//mainClass.set(main)
executableName = "alpha"
arguments(
"--no-fallback",
"-H:Log=registerResource",
"-H:+ReportExceptionStackTraces",
//"-H:ResourceConfigurationFiles=src/main/resources/native-image/resource-config.json",
"--report-unsupported-elements-at-runtime"
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"resources": {
"includes": [
{
"pattern": "alpha-core:/stringtemplates/aggregate-encodings.stg",
"pattern": ".*"
}
]
},
"bundles": []
}

0 comments on commit ba5c7d3

Please sign in to comment.