Index of every page on this site: llms.txt
All skills
github avatar

/java-add-graalvm-native-image-support

@f10fdb8 official
by githubgithub/awesome-copilot42k stars
5,426
Run it yourself

GraalVM Native Image skill for Spring Boot, Micronaut and plain Java: detects the build tool and framework, adds native image support, builds the executable, analyzes errors, and iterates until the native build succeeds and the binary runs correctly. For Quarkus projects it only dispatches to the quarkus-native-and-container skill.

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/java-add-graalvm-native-image-support

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesbuild-tools.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Build tool setup (Maven and Gradle)

Use the GraalVM Native Build Tools plugin for plain Java projects. Quarkus and Micronaut projects get native support (or an equivalent) from their own plugins; do not add it again there. Spring Boot with Maven and spring-boot-starter-parent inherits its version and configuration through the parent's native profile (pluginManagement), but you must still declare native-maven-plugin and spring-boot-maven-plugin in <build><plugins> if absent (no version needed); Spring Boot with Gradle, or Maven with a custom parent, needs the plugin applied explicitly (see spring-boot.md).

Versions

Do not hard-code a version from memory. Resolve the current release at run time and pin it:

  • Maven Central: org.graalvm.buildtools:native-maven-plugin (search.maven.org or https://repo.maven.apache.org/maven2/org/graalvm/buildtools/native-maven-plugin/maven-metadata.xml)
  • Gradle Plugin Portal: org.graalvm.buildtools.native
  • Release notes: https://graalvm.github.io/native-build-tools/latest/index.html

Below, NBT_VERSION stands for the version you resolved. Replace it with the real number in the file.

Maven

Put it in a native profile so normal builds are unaffected:

<profiles>
  <profile>
    <id>native</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.graalvm.buildtools</groupId>
          <artifactId>native-maven-plugin</artifactId>
          <version>NBT_VERSION</version>
          <extensions>true</extensions>
          <executions>
            <execution>
              <id>build-native</id>
              <goals>
                <goal>compile-no-fork</goal>
              </goals>
              <phase>package</phase>
            </execution>
            <execution>
              <id>test-native</id>
              <goals>
                <goal>test</goal>
              </goals>
              <phase>test</phase>
            </execution>
          </executions>
          <configuration>
            <imageName>${project.artifactId}</imageName>
            <mainClass>com.example.Main</mainClass>
            <buildArgs>
              <buildArg>--no-fallback</buildArg>
            </buildArgs>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

Set mainClass to the project's real entry point (or rely on the jar plugin's configured main class). Build: ./mvnw -Pnative native:compile; run tests natively: ./mvnw -Pnative test. The executable lands in target/.

Gradle

Groovy DSL:

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

graalvmNative {
  binaries {
    main {
      imageName = project.name
      mainClass = application.mainClass
      buildArgs.add('--no-fallback')
    }
  }
}

Kotlin DSL:

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

graalvmNative {
  binaries {
    named("main") {
      imageName.set(project.name)
      mainClass.set(application.mainClass)
      buildArgs.add("--no-fallback")
    }
  }
}

Build: ./gradlew nativeCompile; run: ./gradlew nativeRun; test: ./gradlew nativeTest. The executable lands in build/native/nativeCompile/.

Gradle toolchains: to select GraalVM via a toolchain, set javaLauncher in graalvmNative.binaries.main using javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(<java-version>); vendor = JvmVendorSpec.GRAAL_VM }. Otherwise make sure JAVA_HOME points to a GraalVM JDK.

--no-fallback

Fallback images (which bundle a JVM launcher) are deprecated and removed in recent GraalVM releases, so the flag is the default behavior there. Keep it for older toolchains so failures are not hidden.

Useful build arguments

Argument Purpose
-Ob quick build mode for development
--initialize-at-run-time=<class-or-package> defer class initialization
--initialize-at-build-time=<class-or-package> initialize during the build (only when safe)
-H:+ReportExceptionStackTraces fuller build errors
--gc=G1 G1 GC (Linux, Oracle GraalVM) for throughput; default serial GC
-march=native tune for the build CPU only; avoid for distributed binaries (use -march=compatibility)

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning1mo5 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    This skill provides standard and safe instructions for adding GraalVM Native Image support to Java projects. It correctly identifies project frameworks, suggests official build tools, and follows security best practices such as requesting user consent before modifying configurations or dependencies.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

  • Runlayer9mo

    1/1 file flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f10fdb8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated last month
  • graalvm
  • native-image
  • java
  • maven
  • gradle
  • spring-boot
  • quarkus
  • micronaut
  • aot
  • compilation

README badge

README badge for github/awesome-copilot/java-add-graalvm-native-image-support

Adds GraalVM Native Image support to Java applications by detecting the build tool and framework, configuring native image plugins, building iteratively, and applying fixes for reflection, resources, JNI, and proxy issues. Targets Maven and Gradle projects using Spring Boot, Quarkus, Micronaut, or generic Java with framework-specific best practices.

Generated from the current SKILL.md.

Does this skill work with Spring Boot, Quarkus, and Micronaut?
Yes. The skill detects and handles all three frameworks with framework-specific configuration, including Spring AOT RuntimeHints, Quarkus @RegisterForReflection, and Micronaut @Introspected annotations.
What build tools does this skill support?
Maven and Gradle. The skill detects which tool your project uses and applies the native-maven-plugin or org.graalvm.buildtools.native plugin accordingly.
Does this skill automatically resolve native image build errors?
Yes. The skill iteratively analyzes build failures, generates or updates reflection, resource, JNI, and proxy configuration files, and rebuilds until compilation succeeds. It can also run the GraalVM tracing agent to auto-discover configuration requirements.
What happens if my project has custom reflection or JNI requirements?
The skill creates or updates META-INF/native-image config files (reflect-config.json, jni-config.json, resource-config.json, proxy-config.json) to handle them, and for Spring Boot projects can register custom RuntimeHints.

Generated from the current SKILL.md. These answers refresh after source changes.