
Graalvm Native Image
Configure the GraalVM Native Build Tools Gradle plugin so a solo builder can compile Java or Spring Boot apps into fast-start native executables for production.
Overview
graalvm-native-image is an agent skill most often used in Ship (also Build, Operate) that configures Gradle’s GraalVM Native Build Tools plugin to produce native executables from JVM applications.
Install
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill graalvm-native-imageWhat is this skill?
- Documents Native Build Tools plugin 0.10.6 for Kotlin and Groovy build.gradle setups with imageName, mainClass, and Graa
- Includes buildArgs patterns such as --no-fallback and -H:+ReportExceptionStackTraces for diagnosable native compile fail
- Covers Spring Boot Gradle integration, native-mode testing, and multi-project build configuration.
- Standard build entrypoint: ./gradlew nativeCompile produces a project-named native executable.
- Table-of-contents structure spans plugin setup, configuration options, Spring Boot, testing, and multi-project builds.
- Native Build Tools plugin version 0.10.6 documented in setup examples.
- Five major documentation areas: plugin setup, configuration, Spring Boot, native testing, multi-project builds.
- Build command ./gradlew nativeCompile is the documented compile entrypoint.
Adoption & trust: 911 installs on skills.sh; 271 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have a Gradle JVM or Spring Boot project but lack a correct graalvmNative setup, toolchain, and buildArgs to get a working native image instead of a slow or failing nativeCompile.
Who is it for?
Solo builders on Java 21 Gradle projects who deploy Spring Boot or CLI services and want GraalVM native images with documented Spring, test, and multi-project patterns.
Skip if: Teams that only run ./gradlew bootJar in dev, pure frontend or non-JVM stacks, or anyone unwilling to install a GraalVM toolchain and debug native-image reflection metadata.
When should I use this skill?
When adding or fixing GraalVM native image builds in Gradle (Kotlin or Groovy), including Spring Boot native integration, native tests, or multi-project nativeCompile.
What do I get? / Deliverables
You leave with plugin wiring, binary options, and a ./gradlew nativeCompile workflow aligned to your main class and GraalVM JDK so you can ship a native binary and tune perf before production deploy.
- graalvmNative binary configuration in build.gradle(.kts)
- Documented native-image buildArgs and toolchain launcher settings
- Native executable produced via nativeCompile
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Native image compilation is the canonical ship step for JVM apps that need smaller binaries and cold-start performance before or alongside deployment. Perf is the right shelf because GraalVM native builds target runtime startup and resource efficiency, not day-one feature coding.
Where it fits
Wire graalvmNative and mainClass in build.gradle.kts while the API module is still taking shape.
Add --no-fallback and stack-trace reporting before cutting a release native binary for containers.
Align Spring Boot Gradle native profile so launch artifacts match your production entrypoint.
Extend multi-project Gradle so CI runs nativeCompile across modules without one-off scripts.
How it compares
Use this Gradle-native-image skill package instead of guessing native-image flags in ad-hoc shell scripts separate from your build.
Common Questions / FAQ
Who is graalvm-native-image for?
It is for solo and indie builders using Gradle on JVM or Spring Boot apps who need GraalVM native executables for faster startup and leaner production deploys.
When should I use graalvm-native-image?
Use it in Ship when optimizing cold start and image size, in Build when wiring backend Gradle for future native releases, and in Operate when hardening multi-module or native-test CI pipelines.
Is graalvm-native-image safe to install?
Treat it like any third-party agent skill: review the Security Audits panel on this Prism page and inspect the skill source in your repo before letting an agent run Gradle or toolchain commands.
SKILL.md
READMESKILL.md - Graalvm Native Image
# Gradle GraalVM Native Build Tools Plugin Complete Gradle configuration for building GraalVM native images using the Native Build Tools plugin. ## Table of Contents 1. [Plugin Setup](#plugin-setup) 2. [Configuration Options](#configuration-options) 3. [Spring Boot Gradle Integration](#spring-boot-gradle-integration) 4. [Testing in Native Mode](#testing-in-native-mode) 5. [Multi-Project Builds](#multi-project-builds) --- ## Plugin Setup ### Kotlin DSL (`build.gradle.kts`) ```kotlin plugins { java id("org.graalvm.buildtools.native") version "0.10.6" } graalvmNative { binaries { named("main") { imageName.set(project.name) mainClass.set("com.example.Application") buildArgs.add("--no-fallback") buildArgs.add("-H:+ReportExceptionStackTraces") javaLauncher.set(javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(21)) vendor.set(JvmVendorSpec.matching("GraalVM")) }) } } } ``` ### Groovy DSL (`build.gradle`) ```groovy plugins { id 'java' id 'org.graalvm.buildtools.native' version '0.10.6' } graalvmNative { binaries { main { imageName = project.name mainClass = 'com.example.Application' buildArgs.add('--no-fallback') buildArgs.add('-H:+ReportExceptionStackTraces') } } } ``` Build with: ```bash ./gradlew nativeCompile ``` The native executable is produced in `build/native/nativeCompile/`. ## Configuration Options ### Binary Configuration ```kotlin graalvmNative { binaries { named("main") { imageName.set(project.name) mainClass.set("com.example.Application") // Build arguments buildArgs.addAll( "--no-fallback", "-H:+ReportExceptionStackTraces", "--enable-https", "-J-Xmx8g" ) // Quick build mode (faster build, slower runtime — dev only) quickBuild.set(false) // Rich output during build richOutput.set(true) // Verbose output verbose.set(true) // Resource includes resources { autodetect() includedPatterns.add("application.*") includedPatterns.add("META-INF/.*") } } } // GraalVM metadata repository metadataRepository { enabled.set(true) version.set("0.3.14") } // Toolchain detection toolchainDetection.set(true) } ``` ### Java Toolchain Configuration ```kotlin java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } } graalvmNative { binaries { named("main") { javaLauncher.set(javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(21)) vendor.set(JvmVendorSpec.matching("GraalVM Community")) }) } } } ``` ## Spring Boot Gradle Integration For Spring Boot 3.x projects with Gradle: ```kotlin plugins { java id("org.springframework.boot") version "3.4.1" id("io.spring.dependency-management") version "1.1.7" id("org.graalvm.buildtools.native") version "0.10.6" } // Spring Boot plugin automatically configures AOT processing // when GraalVM Native Image plugin is detected ``` Build commands: ```bash # Compile to native executable ./gradlew nativeCompile # Build OCI image with Cloud Native Buildpacks ./gradlew bootBuildImage # Run the native executable ./build/native/nativeCompile/<app-name> # Run AOT processing only ./gradlew processAot ``` ### Custom AOT Configuration ```kotlin tasks.withType<org.springframework.boot.gradle.tasks.aot.ProcessAot>().configureEach { args("--spring.profiles.active=prod") } graalvmNative { binaries { named("main") { buildArgs.addAll( "--n