Skip to content
Skillpedia
APIs & servers (backend)22k · #10356

build-native-image-gradle

What it does

This skill helps Java developers turn their Gradle projects into native programs that start quickly. It is for teams who want lighter, faster Java applications.

When to use it

  • ✓When you want to build a Java application as a GraalVM native image with Gradle.
  • ✓When a native image build fails with class initialization, linking or memory errors.
  • ✓When you need to set up native tests or fix missing reflection metadata for a Gradle project.

Skill link

https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-gradle/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-gradle/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Set up my Gradle Java app to build as a GraalVM native image and run the native tests.”

5 new skills a week. 1 minute to read.

How it works

It adds the GraalVM Native Build Tools plugin to your build file, then runs the native compile, run and test tasks. It uses a GraalVM JDK set as JAVA_HOME and points to guides for known build problems.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Gradle Native Image Build

Prerequisites

  • Set JAVA_HOME to a GraalVM JDK installation so Gradle Native Build Tools can find native-image.
  • Do not require GRAALVM_HOME in the normal case. Only mention it if the user already relies on it or their environment needs an explicit override.
  • Apply the application, java-library, or java plugin along with org.graalvm.buildtools.native.

Plugin Setup

Groovy DSL:

plugins {
    id 'application'
    id 'org.graalvm.buildtools.native' version '0.11.1'
}

Kotlin DSL:

plugins {
    application
    id("org.graalvm.buildtools.native") version "0.11.1"
}

Build and Run

./gradlew nativeCompile   # Build to build/native/nativeCompile/
./gradlew nativeRun       # Build and run the native executable
./gradlew nativeTest      # Build and run JUnit tests as a native image

Build or Runtime Failures

If the build fails with class initialization, linking errors, memory issues, or the binary behaves incorrectly at runtime, see references/native-image-build-gradle-options.md.

Native Testing

If nativeTest fails or you need to configure native JUnit tests or custom test suites, see references/testing.md.

Missing Reachability Metadata

If a build or runtime error reports missing reflection, resource, serialization, or JNI registrations, see references/reachability-metadata.md.

Reference Files

Topic File
DSL options and build arguments references/native-image-build-gradle-options.md
Missing reachability metadata references/reachability-metadata.md
Native testing references/testing.md
FAQ

What Java install does it need?

A GraalVM JDK, set as JAVA_HOME, so the native-image tool can be found.

Does it work with Maven too?

Gradle is covered by this skill, and Maven has its own separate skill.

Does it help with missing metadata?

Yes. It covers missing reflection and resource metadata errors.

Details

Original description by the author

Build GraalVM native images using Gradle Native Build Tools. Use this skill to build Java applications with Gradle, configure native-image build.gradle settings, or resolve build or runtime issues.

repo: oracle/graal

Popularity

GitHub stars
22k
Ranking position
#10356
License
—
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills