Nucleus
Performance & nativeGraalVM Native Image

Configuration

The full graalvm { } DSL — toolchain, image name, march, build args, metadata repository, macOS sub-settings.

nucleus.application.graalvm { … } is the entire GraalVM Gradle surface. The Nucleus plugin extends JetBrains' compose.desktop.application DSL — same shape, plus a graalvm block, the AOT cache flag, store formats, deep links, and the rest. Everything below is Property-typed and lazy.

Quickstart

nucleus.application {
    mainClass = "com.example.MainKt"

    graalvm {
        isEnabled = true
        imageName = "my-app"

        // Gradle Java Toolchain auto-downloads Liberica NIK 25 locally.
        // In CI, set up the JDK with graalvm/setup-graalvm@v1 first.
        javaLanguageVersion = 25
        jvmVendor = JvmVendorSpec.BELLSOFT

        buildArgs.addAll(
            "-H:+AddAllCharsets",
            "-Djava.awt.headless=false",
            "-Os",
            "-H:-IncludeMethodData",
        )

        metadataRepository {
            enabled = true           // default
            version = "0.10.6"       // default
            excludedModules.add("com.example:my-lib")
        }

        // Optional — only if you have app-specific metadata the automatic
        // pipeline doesn't cover. Rare.
        nativeImageConfigBaseDir.set(
            layout.projectDirectory.dir("src/main/graalvm-config"),
        )
    }
}

graalvm { } reference

PropertyTypeDefaultNotes
isEnabledProperty<Boolean>falseMaster switch.
javaLanguageVersionProperty<Int>25Toolchain language version; triggers Gradle auto-download.
jvmVendorProperty<JvmVendorSpec>Set to BELLSOFT to auto-provision Liberica NIK.
imageNameProperty<String>project nameOutput binary name.
marchProperty<String>"native"native for current CPU, compatibility for older CPUs.
buildArgsListProperty<String>emptyExtra args passed to native-image.
nativeImageConfigBaseDirDirectoryPropertyApp-specific reachability-metadata.json directory. Rarely needed.
macOSGraalvmMacOSSettingsmacOS-specific sub-block (see below).
metadataRepositoryMetadataRepositorySettingsenabledOracle Reachability Metadata Repository (see below).
ArgumentPurpose
-H:+AddAllCharsetsInclude every charset — required for text I/O.
-Djava.awt.headless=falseEnable GUI support — mandatory for desktop apps.
-OsOptimise for binary size.
-H:-IncludeMethodDataDrop method metadata; shaves several MB.

metadataRepository { }

The Nucleus plugin auto-downloads the Oracle GraalVM Reachability Metadata Repository and resolves entries for every runtime dependency on your classpath.

PropertyTypeDefaultNotes
enabledProperty<Boolean>trueDisable to skip the repository entirely.
versionProperty<String>"0.10.6"Override the repository artifact version.
excludedModulesSetProperty<String>emptygroup:artifact coordinates to skip.
moduleToConfigVersionMapProperty<String, String>emptyPin the metadata directory version for a given module.
metadataRepository {
    moduleToConfigVersion.put("io.ktor:ktor-client-core", "3.0.0")
    excludedModules.add("group:noisy-lib")
}

macOS { } — GraalvmMacOSSettings

PropertyDefaultNotes
cStubsSrcSource dir for additional C stubs linked into the binary.
minimumSystemVersion"12.0"Mach-O LC_VERSION_MIN_MACOSX patch.
macOsSdkVersion"26.0"SDK version stamped into the launcher's Mach-O headers (controls Liquid Glass eligibility).

No release variant

Unlike the JVM build types, GraalVM has no release variant — no packageReleaseGraalvmNative, no runReleaseGraalvmNative. This is intentional:

  • ProGuard's dead-code elimination is redundant — native-image already does closed-world DCE at compile time.
  • ProGuard can rename classes that are still referenced by reachability-metadata.json, breaking the build silently.

Use -Os in buildArgs for size optimization. No ProGuard.

`nativeImageConfigBaseDir` is usually empty

Nucleus ships all generic and platform-specific metadata automatically. You only need nativeImageConfigBaseDir for app-specific entries the automatic layers don't cover — which is rare. See Automatic metadata for the five layers.