Nucleus
Migrate

Migrate from Nucleus 2.x to 3.0New

Move a Nucleus 2.x app to 3.0. Move to Compose 1.13, rename the window and tray dependencies and packages, remove the backend choice and the AWT windows, and review the runtime and build changes.

View as Markdown

In this tutorial, you'll move a Nucleus 2.x app to 3.0. Fix the compile errors first, then review the runtime and build changes that alter behavior without breaking the build.

Before you start

  • Bump the plugin and every dev.nucleusframework artifact to <version>.
  • Move to Compose Multiplatform 1.13 and Kotlin 2.4.21, and use JDK 17 or later. Nucleus 3.0 ships with Compose 1.13 and does not run on 1.12. See Compatibility.
  • If your app uses decorated-window-jbr or decorated-window-jni, plan time for the AWT removal. It is the largest step.

Review the checklist

Every breaking or behavior change in 3.0, with the step on this page and the feature page.

Compile errors and removed APIs

ChangeWhat to doDocs
Compose Multiplatform 1.12 is not supported. The build fails when Compose resolves to a version older than 1.13.Apply org.jetbrains.compose 1.13 and remove constraints that pin Compose. StepInstall
The decorated-window-* artifacts are renamed window-*: decorated-window-tao is window-runtime. Kotlin packages are unchanged.Rename the dependencies you declare. StepModules
The composenativetray and composenativetray-app artifacts and their dev.nucleusframework.composenativetray packages are gone. The tray is now the tray and tray-app modules, in dev.nucleusframework.tray.Swap the dependency and the imports. StepSystem tray
WindowPositionProvider.CenteredOnScreen and AlignedToScreen are renamed, as in Compose 1.13.Use CenteredInScreenBounds and AlignedToScreenAvailableBounds. StepWindow state
decorated-window-awt, -jbr, -jni deleted. NucleusBackend, LocalNucleusBackend, nucleusApplication(backend = …) and NucleusApplicationScope.backend removed.Drop the dependency and the backend argument. StepWindows
NucleusWindowUnsafe.awtWindow / awtDialog removed. Receiver-less AWT overloads of MaterialDecoratedWindow, MaterialDecoratedDialog, JewelDecoratedWindow, JewelDecoratedDialog removed.Use unsafe.taoWindow and the NucleusApplicationScope receivers. StepToolkits
Compose Desktop's AWT Window, DialogWindow and Tray are unsupported. SwingPanel and AWT Canvas embedding fail at runtime.Import Window and DialogWindow from dev.nucleusframework.application, or use DecoratedWindow, DecoratedDialog, HostedWindow / HostedDialog. Use the Nucleus tray module and NativeView. StepDialogs and popups
Compose's androidx.compose.ui.window.v2 types are not accepted.Import dev.nucleusframework.window.tao.v2 instead. StepWindow state
NucleusWindowHost.Window takes two new parameters, minimizable and maximizable.Add them to your themed host. StepToolkits
Pre-release tool window APIs renamed: SatelliteDragKind is WorkspaceDragKind, TabDropGhost.title is TabDropGhost.tab. The family requires an opt-in.Rename, then opt in to ExperimentalNucleusApi. StepTool windows
TaoMouseButton.OTHER is now 5; 3 and 4 are BACK and FORWARD.Recompile code that reads raw Tao mouse button codes.Mouse buttons
macOS.appStore and TargetFormat.isStoreFormat no longer compile.Use macOS { pkg { appStore = … } } and ExecutableRuntime.isSandboxed(). StepmacOS packaging
GitHubProvider(owner, repo, token) no longer compiles.Drop the token for a public repository, or use PrivateGitHubProvider(owner, repo, token). StepAuto-update
TabHoverPreview.nativeLayer removed.Delete the argument. Open the tab windows with nativePopupLayers = true to let the card hang outside the window. StepTabs

Runtime behavior changes

ChangeWhat to doDocs
Cmd+Q and Dock → Quit call every window's onCloseRequest.Check that your close handlers exit or close. StepApplication
Notification, media control, launcher and global hotkey callbacks run on the host UI thread, not the AWT EDT or a native thread.Remove Swing assumptions in those callbacks. StepThreading
Trackpad pinch arrives as PointerEventType.ScaleStart / ScaleChange / ScaleEnd.Move pinch code to Modifier.transformable or a Scale listener. StepTrackpad gestures
macOS trackpad and Windows precision-touchpad scrolling arrive as PanStart / PanMove / PanEnd.Handle Pan in custom Scroll handlers. StepTrackpad gestures
Single instance is off in dev runs.Pass enableSingleInstance = true to test it from run. StepSingle instance
nucleusApplication initializes FileKit with NucleusApp.appId.Check your FileKit data directory, or opt out. StepFile dialogs
Windows: a hung event loop logs SEVERE with a thread dump.Hook the callbacks or mark long work. StepApplication
Windows: opaque windows render text with LCD (ClearType) antialiasing.Update screenshot baselines, or opt out. StepHiDPI
JRE fonts are stripped from jlink runtime images.Keep them if you draw text through AWT or Swing. StepConfiguration
Nucleus JNI libraries ship next to the packaged app, not inside its JARs.Load them through NativeLibraryLoader, not as resources. StepPackaging
Windows NSIS installs keep the runtime and app in versions\<version>\, and installAndRestart updates without closing the app.Don't build paths from the install root. Call UpdateHandoff.signalReady() if the app shows no Nucleus window.Auto-update
ExecutableRuntime.isSandboxed() returns false in an AppX package.Test ExecutableRuntime.isAppX() to detect AppX. StepExecutable type
Tray menu labels are literal: & and _ are no longer mnemonics, and a - label is an item, not a separator.Use Divider() for separators and drop mnemonic markers. StepTray menu
TaoWindow.setOuterPosition throws IllegalArgumentException for NaN, infinite or out-of-range positions (beyond ±1,000,000 dp).Don't pass sentinels such as Int.MIN_VALUE as a window position.Window state

Build and CI changes

ChangeWhat to doDocs
The plugin downloads Node.js for packaging.Drop setup-node from CI and cache the download. StepCI/CD
nucleusOptimization and its lastJdk knob are opt-in. lastJdk downloads OpenJDK 27.Turn them on if you want them. StepPerformance

New in 3.0, no action required

ChangeWhen it mattersDocs
TaoWindow.canPlaceOnScreen and SatelliteScope.isCompositorPlaced report native Wayland placement.Chrome that reads window positions on Linux. StepLinux and Wayland
nucleusApplication(exitProcessOnExit = true) is the default.Pass false to keep running after the last window.Application
-Dnucleus.native.cacheDir and NativeLibraryLoader.cacheDirectory relocate the native library cache.Fat JARs, IDE runs, distributions built without the plugin. StepPackaging

Move to Compose 1.13

Nucleus 3.0 is built against Compose Multiplatform 1.13 internals, so it fails at run time on 1.12 with NoClassDefFoundError or NoSuchMethodError. The plugin checks it at build time instead.

  1. Bump the Compose plugin and Kotlin:

    build.gradle.kts
     plugins {
    -    kotlin("jvm") version "2.4.20"
    -    kotlin("plugin.compose") version "2.4.20"
    -    id("org.jetbrains.compose") version "1.12.1"
    +    kotlin("jvm") version "2.4.21"
    +    kotlin("plugin.compose") version "2.4.21"
    +    id("org.jetbrains.compose") version "1.13.0"
         id("dev.nucleusframework") version "3.0.0"
     }
  2. Remove strictly, force or BOM constraints that hold org.jetbrains.compose.ui:ui-desktop below 1.13. If one is left, the build fails with Nucleus requires Compose Multiplatform 1.13 or newer.

  3. Bump the libraries that follow Compose, such as Material 3 and Jewel. The Jewel adapter is built against Jewel 0.43.0-263.8311.126. See Jewel.

An org.jetbrains.compose plugin older than 1.13 only logs a warning, because Gradle upgrades the Compose libraries anyway. Upgrade it all the same: it injects a Compose Hot Reload agent that Tao does not support.

Rename the window modules

decorated-window-tao is the only window runtime, not one decoration among several, so the decorated-window-* family is now window-*. Only the Gradle coordinates move: the Kotlin packages and the imports stay the same.

Nucleus 2.xNucleus 3.0
nucleus.decorated-window-taonucleus.window-runtime
nucleus.decorated-window-corenucleus.window-core
nucleus.decorated-window-jewelnucleus.window-jewel
nucleus.decorated-window-material2nucleus.window-material2
nucleus.decorated-window-material3nucleus.window-material3
build.gradle.kts
 dependencies {
     implementation("dev.nucleusframework:nucleus.nucleus-application:3.0.0")
-    implementation("dev.nucleusframework:nucleus.decorated-window-material3:3.0.0")
+    implementation("dev.nucleusframework:nucleus.window-material3:3.0.0")
 }

An app that only depends on nucleus-application gets window-runtime and window-core transitively and has nothing to rename. Also rename the modules in version catalogs, dependency locks, exclude(module = …) rules and GraalVM or ProGuard configuration.

Remove the backend selection

Tao is the only window runtime in 3.0, and nucleus-application brings it along.

  1. Remove decorated-window-jbr, decorated-window-jni, decorated-window-awt and decorated-window-tao (now window-runtime) from every module's dependencies.

  2. Drop the backend argument and the NucleusBackend import. Delete reads of LocalNucleusBackend and NucleusApplicationScope.backend, and keep the Tao branch of backend-specific code:

    -fun main(args: Array<String>) = nucleusApplication(args, backend = NucleusBackend.Tao) {
    +fun main(args: Array<String>) = nucleusApplication(args) {
  3. Replace nucleusWindow.unsafe.awtWindow with unsafe.taoWindow, or unsafe.taoHandle for the native handle. Check NucleusWindow first: toFront(), setMinimumSize(), setIcon() and boundsOnScreen() cover most calls.

  4. Call the Material and Jewel windows and dialogs on a NucleusApplicationScope, because the receiver-less AWT overloads are gone. Inside nucleusApplication { } nothing changes. Deeper in the composition, read the scope from LocalNucleusApplicationScope:

    val scope = LocalNucleusApplicationScope.current
    scope.MaterialDecoratedWindow(onCloseRequest = onClose, title = "Editor") { EditorContent() }

Replace Compose Desktop windows, dialogs, and tray

Nucleus 3.0 never creates an AWT window, so Compose Desktop's Window, DialogWindow and Tray fail under nucleusApplication. Swap each for its Nucleus counterpart:

Compose Desktop (AWT)Nucleus 3.0
Window(…)Window(…) from dev.nucleusframework.application, DecoratedWindow(…) for a Compose title bar, or HostedWindow(…) in library code
DialogWindow(…)DialogWindow(…) from dev.nucleusframework.application, DecoratedDialog(…), or HostedDialog(…) in library code
Tray(…) from androidx.compose.ui.windowTray(…) from the Nucleus tray module
SwingPanel, AWT CanvasNativeView
JFileChooser, java.awt.FileDialogFileKit
window.window (ComposeWindow)nucleusWindow and LocalNucleusWindow

The Nucleus Window and DialogWindow take Compose's parameters, so the import is the only change. The platform draws their title bar. If a file also imports androidx.compose.ui.window.*, import dev.nucleusframework.application.Window explicitly, or the call is ambiguous. See Choose a window kind.

DecoratedWindow and DecoratedDialog take the same onCloseRequest and title arguments, and draw the title bar in Compose. HostedWindow and HostedDialog wear the toolkit the app provides, so a library does not pick a look.

For the tray, add dev.nucleusframework:nucleus.tray:3.0.0 and import dev.nucleusframework.tray.Tray. Its API differs from Compose's Tray, so port the menu with the tray menu DSL.

AWT classes that don't need a window keep working: BufferedImage, ImageIO, java.awt.Font, and the AWT clipboard. APIs that need a window or the AWT event loop do not.

Move the tray to the Nucleus tray modules

ComposeNativeTray now lives in Nucleus, split in two modules that share the Nucleus version:

  • tray (dev.nucleusframework:nucleus.tray): the icon, the native menu and the Tray(…) composables. It needs no window runtime, so a daemon or an app without windows can use it.
  • tray-app (dev.nucleusframework:nucleus.tray-app): TrayApp, the icon that toggles a popup anchored to it. It brings tray and nucleus-application.
  1. Replace the dependency:

    build.gradle.kts
     dependencies {
    -    implementation("dev.nucleusframework:composenativetray:<tray-version>")
    -    implementation("dev.nucleusframework:composenativetray-app:<tray-version>")
    +    implementation("dev.nucleusframework:nucleus.tray:3.0.0")
    +    // Only if you use TrayApp
    +    implementation("dev.nucleusframework:nucleus.tray-app:3.0.0")
     }
  2. Replace the imports. The .api segments are gone and trayapp is now tray.app:

    ComposeNativeTrayNucleus 3.0
    dev.nucleusframework.composenativetray.tray.api.Traydev.nucleusframework.tray.Tray
    dev.nucleusframework.composenativetray.menu.api.* (Key, KeyShortcut)dev.nucleusframework.tray.menu.*
    dev.nucleusframework.composenativetray.trayapp.* (TrayApp, rememberTrayAppState)dev.nucleusframework.tray.app.*
    -import dev.nucleusframework.composenativetray.tray.api.Tray
    -import dev.nucleusframework.composenativetray.trayapp.TrayApp
    +import dev.nucleusframework.tray.Tray
    +import dev.nucleusframework.tray.app.TrayApp
  3. Check the menu labels. They are shown as written: & (Windows) and _ (Linux) are no longer eaten as mnemonics, and a - label is a plain item. Use Divider() for separators.

Under GNOME, the AppIndicator extension opens the menu on a single click and calls the primary action on a double click, so a TrayApp popup opens on a double click there. See System tray.

Switch window state to the Nucleus v2 package

Compose 1.13's window API v2 depends on AWT, so Nucleus ships a copy with the same members. Change the import of rememberWindowState, WindowState, DialogState, Screen, the geometry providers and the remember* factories:

-import androidx.compose.ui.window.v2.rememberWindowState
+import dev.nucleusframework.window.tao.v2.rememberWindowState

Compose 1.13 renamed two position providers, and Nucleus follows:

-positionProvider = WindowPositionProvider.CenteredOnScreen,
+positionProvider = WindowPositionProvider.CenteredInScreenBounds,
-positionProvider = WindowPositionProvider.AlignedToScreen(Alignment.TopEnd),
+positionProvider = WindowPositionProvider.AlignedToScreenAvailableBounds(Alignment.TopEnd),

The v1 androidx.compose.ui.window.WindowState keeps working. See Window state.

Update custom window hosts

NucleusWindowHost.Window takes minimizable: Boolean and maximizable: Boolean after resizable. A themed host must add both and pass them on. They default to true on DecoratedWindow and HostedWindow, and DecoratedDialog passes false. NucleusDialogHost is unchanged.

Opt in to the tool window APIs

Satellites, the dock layout and tabs are @ExperimentalNucleusApi at ERROR level. Opt in per call site or per module:

build.gradle.kts
kotlin {
    compilerOptions {
        optIn.add("dev.nucleusframework.window.ExperimentalNucleusApi")
    }
}

If you used a pre-release build, rename SatelliteDragKind to WorkspaceDragKind (it now serves both workspaces) and dropGhost.title to dropGhost.tab.title.

On native Wayland, the app can neither read nor set window screen positions. Branch on TaoWindow.canPlaceOnScreen (or SatelliteScope.isCompositorPlaced in a satellite), not on the compositor name. See Linux and Wayland.

Replace the PKG store flags

A PKG now targets either the Mac App Store or Developer ID. Move the flag into the pkg { } block:

build.gradle.kts
 macOS {
-    appStore = true
+    pkg { appStore = true } // default; false builds a Developer ID PKG
 }

In runtime code, replace ExecutableRuntime.isPkg() and isStoreFormat checks with ExecutableRuntime.isSandboxed(). A Developer ID PKG is not sandboxed, so it can update itself. See Sandboxing.

Move private repositories to PrivateGitHubProvider

GitHubProvider takes no token in 3.0, so GitHubProvider(owner, repo, token) no longer compiles. For a public repository, drop the token. For a private repository or a GitHub Enterprise Server, switch to PrivateGitHubProvider:

-provider = GitHubProvider(owner = "myorg", repo = "myapp", token = token)
+provider = PrivateGitHubProvider(owner = "myorg", repo = "myapp", token = token)

Pass host by name. See Read updates from GitHub Releases.

Update tab hover previews

TabHoverPreview lost its nativeLayer parameter. Delete the argument. The card now opens like the window's other popups: in the windows TabWindows opens, it draws inside the window, clipped by it. To let it hang below the window, open the tab windows yourself with nativePopupLayers = true. See Draw previews.

Review runtime behavior changes

These changes compile without errors. Check each one against your app.

Check your close handlers

On macOS, Cmd+Q and Dock → Quit now call onCloseRequest on every open window, as on Windows and Linux. A handler that neither calls exitApplication() nor closes its window cancels the quit. A hide-to-tray handler lets the quit through while NucleusApplicationScope.isQuitting is true. See Application.

Move native callbacks off the AWT EDT

notification-linux, notification-windows, media-control, launcher-linux and launcher-macos callbacks run on the host UI thread. Compose state writes keep working. Remove SwingUtilities.isEventDispatchThread() checks and Swing calls from them. See Threading.

Handle pinch and pan events

A trackpad pinch or Ctrl+wheel arrives as ScaleStart / ScaleChange / ScaleEnd, which detectTransformGestures does not see: use Modifier.transformable. On macOS and on a Windows precision touchpad, scrolling arrives as PanStart / PanMove / PanEnd. Modifier.scrollable handles it, but a custom Scroll handler must handle Pan too:

when (event.type) {
    PointerEventType.Scroll -> offset += change.scrollDelta * stepPx
    PointerEventType.PanMove -> offset += change.panOffset
    PointerEventType.ScaleChange -> zoom *= change.scaleFactor
}

-Dnucleus.tao.trackpadPanEvents=false sends trackpad scrolling as Scroll. See Trackpad gestures.

Test single instance in dev runs

A second ./gradlew run or IDE launch now starts a separate instance. Packaged builds keep the lock. To test the forwarding from run, pass nucleusApplication(args, enableSingleInstance = true).

Check the FileKit initialization

When FileKit is on the classpath, nucleusApplication calls FileKit.init(NucleusApp.appId), so dev runs, packaged apps and native images share one data directory. A FileKit.init call before nucleusApplication keeps your configuration. Pass initializeFileKit = false to leave FileKit untouched.

Handle the event-loop watchdog

On Windows, a stuck event loop now logs SEVERE with a thread dump. Show your own UI from the callbacks, and wrap known long synchronous work so it is not reported:

nucleusApplication(args) {
    onUnresponsive { showWaitOrQuit() }
    onResponsive { hideWaitOrQuit() }
    expectUnresponsive { importHugeProjectSynchronously() }
}

-Dnucleus.tao.watchdog=false disables the watchdog.

Review LCD text on Windows

Opaque windows on Windows now render text with ClearType antialiasing, which changes screenshots. Update your baselines, or opt out with -Dnucleus.text.lcd=false at run time or -Pnucleus.text.lcd.patch=false at build time.

Keep JRE fonts for AWT text

The jlink runtime image no longer ships the JRE fonts, because Compose draws with its own. If you render text through AWT or Swing, set stripJreFonts = false in nativeDistributions.

Load Nucleus native libraries through the loader

Packaged apps carry Nucleus JNI libraries next to the app instead of inside the module JARs. Code that read them as JAR resources must call NativeLibraryLoader.load(…). Your own libraries under nucleus/native/ stay in their JARs.

Detect AppX with isAppX

An AppX package runs with full trust, so ExecutableRuntime.isSandboxed() now returns false there. Code that relied on isSandboxed() to detect AppX must test ExecutableRuntime.isAppX(). See Build an AppX or MSIX package.

Update the build and CI

Drop Node.js from CI

The plugin downloads the Node.js that packaging needs. Remove actions/setup-node from your workflows and add ~/.gradle/nucleus/nodejs to your cache paths. To keep the node on PATH, set nodejs { autoDownload = false } in nativeDistributions. See CI/CD.

Opt in to the startup pack

nucleusOptimization is off by default. One switch turns on Serial GC, a compact heap, a single runtime JAR, idle GC and lastJdk (OpenJDK 27). Override single knobs in the block:

build.gradle.kts
nucleus.application {
    nucleusOptimization = true
    nucleusOptimization { lastJdk = false }
}

An explicit javaHome wins over lastJdk. See Performance.

Retest the app

Run the app, then exercise each integration that used to depend on AWT:

  • Drag and drop. Rewrite handlers that read AWT TransferHandler data. See Drag and drop.
  • Deep links. onDeepLink { uri -> … } is unchanged.
  • File dialogs and embedded views. Check every FileKit picker and NativeView.
  • Window placement on Linux. Wayland compositors ignore absolute positions.
  • Quit flows on macOS, and every close handler.
  • Packaging. Build each installer format once, and a native image if you ship one.

What's next

Was this page helpful?
Edit on GitHub

Last updated on