native-image-playground

GraalVM Native Image Playground

GitHub Workflow Status GraalVM CE Kotlin release Style guide

GraalVM Native Image of a kotlin/java app and publish the platform binaries using GitHub action.

Install GraalVM CE Dev

# Install GraalVM CE Dev
$ ./scripts/graalvm-ce-dev.sh

# Install GraalVM CE
$ curl -s "https://get.sdkman.io" | bash
$ sdk i java 22.0.1-graalce

Build

# Build the native image
$ ./gradlew nativeCompile

# Use trace agent for metadata generation
$ ./gradlew -Pagent run [--rerun-tasks]
# Gracefully shutdown the server instead of killing Gradle run.
$ curl http://localhost:9080/shutdown
$ ./gradlew metadataCopy

# Run native image tests
$ ./gradlew nativeTest
$ ./gradlew -Pagent nativeTest

# Native Image Quick Build
$ ./gradlew nativeCompile -Pquick

# Build Native Image Bundles
$ ./gradlew nativeCompile -Pbundle
$ native-image --bundle-apply="build/native/nativeCompile/native-image-playground.nib"
$ build/native-image-playground.output/default/native-image-playground

# Build by disabling the build cache
$ ./gradlew clean nativeCompile --rerun-tasks --no-build-cache

# GraalVM JIT Mode
$ ./gradlew build
$ java --enable-preview \
       --add-modules=ALL-SYSTEM \
       -jar build/libs/native-image-playground-*-all.jar

# Find out the classes/jars using top modules mentioned in the native-image build output
$ jdeps -q \
        -R \
        --ignore-missing-deps \
        --multi-release=24 \
        build/libs/native-image-playground-*-all.jar

# Build native image from modular jars
$ native-image \
    -p base-module.jar:main-module.jar \
    -m dev.suresh.Main

Run & Debugging

Resources