build: align Compose Multiplatform versions and exclude transitive BOMs (#5103)

This commit is contained in:
James Rich 2026-04-13 07:02:52 -05:00 committed by GitHub
parent 4dd591af25
commit 35bf1fded5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 4 deletions

View file

@ -24,9 +24,17 @@ import org.gradle.kotlin.dsl.dependencies
internal fun Project.configureAndroidCompose(commonExtension: CommonExtension) {
commonExtension.apply { buildFeatures.compose = true }
// CMP skips Android version enforcement; third-party BOMs and atomic-group alignment
// can silently override AndroidX Compose versions. Force core groups to the CMP version.
// Material/Material3 excluded — CMP maps those to different AndroidX version numbers.
// CMP is the sole Compose version authority (BOM removed from the catalog).
// Third-party libraries (maps-compose, datadog, etc.) carry a transitive
// compose-bom whose constraints conflict with CMP-published AndroidX artifacts.
// Exclude it globally so CMP's own dependency graph wins.
configurations.configureEach {
exclude(mapOf("group" to "androidx.compose", "module" to "compose-bom"))
}
// CMP publishes these core AndroidX groups at the CMP version tag.
// Material, Material3, and Adaptive follow separate AndroidX version numbers
// and must NOT be included here (see CMP release notes for the mapping table).
val cmpVersion = libs.version("compose-multiplatform")
val cmpAlignedGroups = setOf(
"androidx.compose.animation",
@ -34,10 +42,18 @@ internal fun Project.configureAndroidCompose(commonExtension: CommonExtension) {
"androidx.compose.runtime",
"androidx.compose.ui",
)
// The BOM exclusion above strips versions from transitive material deps
// (e.g. maps-compose-widgets, datadog). Pin the material group to the
// AndroidX version that matches this CMP release.
val materialVersion = libs.version("androidx-compose-material")
configurations.configureEach {
resolutionStrategy.eachDependency {
if (requested.group in cmpAlignedGroups) {
useVersion(cmpVersion)
} else if (requested.group == "androidx.compose.material") {
useVersion(materialVersion)
}
}
}

View file

@ -36,6 +36,7 @@ turbine = "1.2.1"
# Compose Multiplatform
compose-multiplatform = "1.11.0-beta02"
compose-multiplatform-material3 = "1.11.0-alpha06"
androidx-compose-material = "1.7.8"
jetbrains-adaptive = "1.3.0-alpha06"
# Google
@ -118,7 +119,7 @@ androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version
androidx-work-testing = { module = "androidx.work:work-testing", version = "2.11.2" }
# AndroidX Compose (explicit versions — BOM removed; CMP is the sole version authority)
androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version = "1.7.8" } # Only used by deprecated mesh_service_example — remove when that module is deleted
androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "androidx-compose-material" } # Only used by deprecated mesh_service_example — remove when that module is deleted
androidx-compose-runtime-tracing = { module = "androidx.compose.runtime:runtime-tracing", version.ref = "compose-multiplatform" }
androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose-multiplatform" } # Required by Robolectric Compose tests (registers ComponentActivity)