Skip to content

fix(plugin): allow applying org.jetbrains.compose alongside Nucleus#331

Merged
kdroidFilter merged 1 commit into
mainfrom
fix/compose-plugin-coexistence
Jul 13, 2026
Merged

fix(plugin): allow applying org.jetbrains.compose alongside Nucleus#331
kdroidFilter merged 1 commit into
mainfrom
fix/compose-plugin-coexistence

Conversation

@kdroidFilter

Copy link
Copy Markdown
Collaborator

Fixes #284.

Summary

Nucleus forks the Compose Desktop packaging and duplicated two of the Compose plugin's registrations, causing order-dependent conflicts when both org.jetbrains.compose and the Nucleus plugin are applied to the same module (commonly surfaced during IntelliJ Gradle sync).

Two distinct bugs, both fixed:

  1. Duplicate jetbrainsCompose extension (nucleus-before-compose order) — the Groovy-DSL setup was gated behind !project.buildFile.endsWith(".gradle.kts"). File.endsWith(String) matches by path components, not by string suffix, so File("build.gradle.kts").endsWith(".gradle.kts") is always false → the Groovy setup ran for Kotlin DSL projects too and registered a jetbrainsCompose repositories extension, which the Compose plugin then fails to add.

  2. Task-name collision (compose-before-nucleus order + mainClass set) — propagateMainClassToComposeApplication called the lazy getApplication getter, which initializes compose.desktop.application as a side effect, making the Compose plugin register its own packaging tasks that collide with Nucleus's identically-named ones (unpackDefaultComposeDesktopJvmApplicationResources, createDistributable, packageDmg, …).

Changes

  • Detect Kotlin DSL via buildFile.name.endsWith(".gradle.kts") so the Groovy setup only runs for Groovy build files.
  • Forward mainClass only when Compose's application is already initialized (explicit block or Hot Reload plugin), read via the internal _isJvmApplicationInitialized flag without triggering initialization. Nucleus therefore never causes Compose to register packaging tasks — only Nucleus's forked, modified tasks exist.
  • Fail fast with an actionable message when both nucleus.application { } and compose.desktop.application { } are configured (the Compose plugin can stay applied for Hot Reload / IDE integration).

Test plan

  • Reproduced [Enhancement] Decouple Nucleus Plugin from Compose Desktop #284 on a vanilla CMP template + the reporter's repo (published 2.0.1)
  • nucleus-before-compose order: no longer crashes on jetbrainsCompose
  • compose-before-nucleus order (no compose block): :desktopApp:run succeeds
  • Both blocks configured: clear actionable error instead of cryptic Gradle failure
  • Packaging task classes are 100% dev.nucleusframework.* even with org.jetbrains.compose applied (no Compose Desktop tasks used)
  • Compose Hot Reload (runHot) still starts
  • :plugin:test, ktlint and detekt pass

Nucleus forks the Compose Desktop packaging and duplicated two of the
Compose plugin's registrations, causing order-dependent conflicts when
both plugins are applied to the same module:

- The Groovy-DSL setup guard used File.endsWith(String), which matches
  by path components (never a suffix), so it ran for Kotlin DSL projects
  too and registered a 'jetbrainsCompose' repositories extension that
  clashes with the Compose plugin.
- propagateMainClassToComposeApplication called the lazy getApplication
  getter, initializing compose.desktop.application and making the Compose
  plugin register its own packaging tasks, which collide with Nucleus's
  identically-named ones (unpackDefaultComposeDesktopJvmApplicationResources,
  createDistributable, packageDmg, ...).

Fixes:
- Detect Kotlin DSL via buildFile.name so the Groovy setup only runs for
  Groovy build files.
- Only forward mainClass when Compose's application is already initialized,
  read via the internal _isJvmApplicationInitialized flag without triggering
  initialization. Nucleus therefore never causes Compose to register its
  packaging tasks; only Nucleus's forked tasks exist.
- Fail fast with an actionable message when both nucleus.application and
  compose.desktop.application are configured.
@kdroidFilter kdroidFilter merged commit de11035 into main Jul 13, 2026
12 checks passed
@kdroidFilter kdroidFilter deleted the fix/compose-plugin-coexistence branch July 13, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Decouple Nucleus Plugin from Compose Desktop

1 participant