One DSL, eighteen installers
Declare the desktop distribution formats you need in the Gradle plugin's DSL and build each one the host operating system supports.
Nucleus declares every desktop distribution format in one nucleus { } Gradle block. You choose the
formats with targetFormats(...), and a single task builds each one the host operating system can
produce. TargetFormat defines 18 formats, covering direct installers, store packages, and plain
archives.
Declare the formats
The packaging DSL ships with the Gradle plugin, so there is no separate dependency to add:
plugins {
id("dev.nucleusframework") version "2.0.7"
}List the formats you want inside nativeDistributions:
nucleus {
application {
mainClass = "com.example.MainKt"
nativeDistributions {
targetFormats(
TargetFormat.Dmg, TargetFormat.Pkg,
TargetFormat.Exe, TargetFormat.Nsis, TargetFormat.Msi, TargetFormat.AppX,
TargetFormat.Deb, TargetFormat.Rpm, TargetFormat.AppImage, TargetFormat.Pacman,
TargetFormat.Snap, TargetFormat.Flatpak,
TargetFormat.Zip,
)
packageName = "MyApp"
packageVersion = "1.0.0"
}
}
}Build the installers
./gradlew packageDistributionForCurrentOSEvery format requested for the host operating system is written under build/compose/binaries/.
Formats the host operating system cannot produce are skipped silently. The same build script runs unchanged on macOS, Windows, and Linux, which suits matrix CI.
Supported formats
TargetFormat defines 18 constants. The table groups them by how you ship each build:
| OS | Direct distribution | Store | Archives |
|---|---|---|---|
| macOS | DMG | PKG (Mac App Store) | ZIP, TAR, 7z |
| Windows | Exe, NSIS, MSI, Portable | AppX (Microsoft Store) | ZIP, TAR, 7z |
| Linux | DEB, RPM, AppImage, Pacman | Snap, Flatpak | ZIP, TAR, 7z |
The full set of enum constants is RawAppImage, Pkg, Deb, Rpm, Dmg, Exe, Msi, Nsis,
NsisWeb, Portable, AppX, AppImage, Pacman, Snap, Flatpak, Zip, Tar, and SevenZ.
Pass any of them to targetFormats(...). The declaring type is
dev.nucleusframework.desktop.application.dsl.TargetFormat.
How it works
Nucleus runs jpackage to produce a platform app-image, then hands that image to electron-builder's
--prepackaged mode to drive each installer format. The hybrid keeps jpackage's JVM runtime tuning
while using electron-builder for the formats jpackage does not support, such as NSIS, AppX, Snap,
Flatpak, and AppImage.
When you mix direct-distribution formats with store formats, Nucleus runs two pipelines: a regular
createDistributable for formats like DMG, NSIS, and DEB, and a createSandboxedDistributable for
the store formats PKG, AppX, and Flatpak. The sandboxed pipeline pre-extracts native libraries,
injects sandbox-aware JVM arguments, and applies the matching entitlements. See
Sandboxing.
Configure each platform
Per-OS settings live under nativeDistributions.macOS { }, windows { }, and linux { }:
- Building for macOS — DMG, PKG, universal binaries, and layered icons.
- Building for Windows — Exe, NSIS, MSI, AppX, and Portable.
- Building for Linux — DEB, RPM, AppImage, Pacman, Snap, and Flatpak.
What's next
- Code signing — sign and notarize builds for each platform.
- Publishing — push installers to GitHub Releases, S3, or a generic host.
- Gradle DSL reference — the full
nucleus { }DSL.