Files
Bitsy fb8e97b74d feat(material3): port material3-adaptive to desktop native
Closes the request in issue #4. org.jetbrains.compose.material3.adaptive:*
1.3.0-rc01 publishes ios_arm64 / ios_simulator_arm64 / macos_arm64 and
nothing else - no linux, no mingw. (It does carry macosArm64, which
answers the reporter's open question.)

All four artifacts are now vendored and built for every desktop-native
target, with ZERO source edits. Two things made it a pure re-target:

- every platform actual the native legs need already exists upstream:
  adaptive/nonAndroidMain (calculatePosture), adaptive-layout/skikoMain
  (~75 l10n tables + Strings + the drag handle) and
  adaptive-layout/nativeMain (identityHashCode, isGraphicsLayerElement)
- androidx.window:window-core - the dependency `adaptive` api-exposes and
  the obvious suspect for the apple-only publication - has shipped
  linux_x64 / linux_arm64 / mingw_x64 / macos_arm64 klibs all along, under
  BOTH the google and jetbrains coordinates

So the artifacts were missing only because upstream never enabled the
targets, not because anything blocked them.

125 files vendored off the existing COMPOSE_CORE_REF pin - no new
SET_REPO. Upstream's skikoMain lands in src/vendor/native/ beside
upstream's own nativeMain; the two actualise disjoint expects so they
share one source set.

Both bridges substitute all four coordinates, so consumers keep declaring
the official org.jetbrains.compose.material3.adaptive:* coords.

Verified: all four compile for mingwX64 + linuxX64 + linuxArm64, API
dumps generated, vendor-clean and audit-exclusions pass, and
`demo --screen=Adaptive` renders a live ListDetailPaneScaffold with the
window size class resolving correctly. adaptive-navigation3 builds and
dumps API but has no demo screen yet, so its nav3 SceneStrategy path is
unproven at runtime.

Two notes for later:
- the new demo screen hit the granular-metadata trap documented in
  CLAUDE.md: because `adaptive` is substituted on native configs, KGP
  drops its transitives from the commonMain metadata classpath, so
  window-core had to be declared DIRECTLY in demo's commonMain
- demo's JVM parity leg moves navigation3-ui 1.2.0-alpha02 -> 1.1.2 to
  follow CMP 1.12.1's navigation3 reset onto the 1.1 line
2026-09-22 16:07:23 +02:00

129 lines
5.3 KiB
Kotlin

import com.bitsycore.compose.sdl.build.registerComposeFontBundling
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.plugin.compose)
alias(libs.plugins.compose.multiplatform)
id("com.bitsycore.compose-desktop-native.bridge")
}
val isHostMingwCompatible = rootProject.extra["vHostSupportsMingw"] as Boolean
kotlin {
jvm()
buildList {
add(linuxArm64())
add(linuxX64())
add(macosArm64())
if (isHostMingwCompatible) add(mingwX64())
}.forEach {
it.binaries {
executable {
when {
target.name == "mingwX64" -> linkerOpts(
// crypt32: client-cert (mTLS) import into the Windows cert store.
"-lcrypt32",
"-Wl,--gc-sections", "-Wl,-s",
// GUI subsystem (no console window), keeping the C `main` entry.
"-Wl,--subsystem,windows", "-Wl,-e,mainCRTStartup",
)
target.name.startsWith("linux") -> linkerOpts(
"-L/usr/lib/x86_64-linux-gnu", "-L/usr/lib/aarch64-linux-gnu",
"-lfontconfig", "-lGL", "-lX11",
)
}
}
}
}
applyDefaultHierarchyTemplate()
sourceSets {
commonMain {
dependencies {
val vComposeJvmVersion = libs.versions.compose.get()
val vComposeM3JvmVersion = libs.versions.composeMaterial3.get()
val vAdaptiveJvmVersion = libs.versions.composeMaterial3Adaptive.get()
// Official Maven coords for everything the shared UI touches; native
// configurations substitute them for the port modules automatically
// (root bridge in-repo, the bridge plugin for consumers).
implementation("org.jetbrains.compose.runtime:runtime:${libs.versions.composeRuntime.get()}")
implementation("org.jetbrains.compose.ui:ui:$vComposeJvmVersion")
implementation("org.jetbrains.compose.ui:ui-graphics:$vComposeJvmVersion")
implementation("org.jetbrains.compose.ui:ui-text:$vComposeJvmVersion")
implementation("org.jetbrains.compose.ui:ui-unit:$vComposeJvmVersion")
implementation("org.jetbrains.compose.ui:ui-geometry:$vComposeJvmVersion")
implementation("org.jetbrains.compose.ui:ui-util:$vComposeJvmVersion")
implementation("org.jetbrains.compose.ui:ui-tooling-preview:${vComposeJvmVersion}")
implementation("org.jetbrains.compose.foundation:foundation:$vComposeJvmVersion")
implementation("org.jetbrains.compose.foundation:foundation-layout:$vComposeJvmVersion")
implementation("org.jetbrains.compose.animation:animation:$vComposeJvmVersion")
implementation("org.jetbrains.compose.animation:animation-core:$vComposeJvmVersion")
implementation("org.jetbrains.compose.components:components-resources:${vComposeJvmVersion}")
implementation("org.jetbrains.compose.material3:material3:$vComposeM3JvmVersion")
implementation("org.jetbrains.compose.material3.adaptive:adaptive:$vAdaptiveJvmVersion")
implementation("org.jetbrains.compose.material3.adaptive:adaptive-layout:$vAdaptiveJvmVersion")
implementation("org.jetbrains.compose.material3.adaptive:adaptive-navigation:$vAdaptiveJvmVersion")
// adaptive api-exposes window-core (WindowSizeClass). Because `adaptive`
// is SUBSTITUTED on native configs, KGP's granular-metadata visibility
// check drops its transitives from the commonMain classpath - so the
// shared screen only sees WindowSizeClass if we declare it DIRECTLY.
implementation(libs.androidx.window.core)
// Common Material Symbols Utility
implementation(project(":utils:material-symbols"))
// nav3 + lifecycle: real KMP Maven artifacts on every target
implementation(libs.androidx.navigation3.runtime)
implementation("org.jetbrains.androidx.navigation3:navigation3-ui:1.1.2")
implementation(libs.androidx.lifecycle.viewmodel.navigation3)
}
}
nativeMain {
dependencies {
implementation(project(":compose:desktop:native:desktop-native-window"))
}
}
jvmMain {
dependencies {
implementation(libs.androidx.navigation3.runtime)
implementation(compose.desktop.currentOs)
}
}
}
compilerOptions {
freeCompilerArgs.addAll(
"-Xcollection-literals",
"-Xexpect-actual-classes",
"-opt-in=kotlinx.cinterop.ExperimentalForeignApi"
)
}
}
compose.desktop {
application {
mainClass = "MainJvmKt"
}
}
compose.desktop.native {
entryPoint = "main"
}
compose.resources {
packageOfResClass = "demo.generated.resources"
}
registerComposeFontBundling {
bundleNotoSans = true
autoDetectNotoSansMono = true
bundleMaterialSymbols = true
}
// The mingwX64 skiko-windows-x64.dll is provisioned automatically by the bridge
// plugin (see installWindowsSkiaDll).