eygraber
11/24/2022, 4:38 AMconfigurations.configureEach {
resolutionStrategy {
eachDependency {
val isCompiler = requested.group.endsWith("compiler")
if(requested.group.startsWith("androidx.compose")) {
if(!isCompiler) {
useVersion(versionOverride)
}
}
}
}
}
Now that Jetpack Compose provides a BOM, what would be the best way to do this?
Any chance that Jetbrains Compose can expose a property for setting the BOM version to use?Dima Avdeev
11/24/2022, 7:04 AMeygraber
11/24/2022, 10:28 PMeygraber
11/24/2022, 10:30 PMandroidx.compose.ui:ui:<some version>
But to work with the BOM it would need to be androidx.compose.ui:ui
eygraber
11/25/2022, 8:27 AMandroid {
dependencies {
// jetbrains compose plugin rewrites compose dependencies for android to point to androidx
// if we want to use the compose BOM we need to rewrite the rewritten dependencies to not include a version
components {
all {
val isCompiler = id.group.endsWith("compiler")
val isCompose = id.group.startsWith("androidx.compose")
val isBom = id.name == "compose-bom"
val override = isCompose && !isCompiler && !isBom
if(override) {
// copied from Jetbrains Compose RedirectAndroidVariants
// <https://github.com/JetBrains/compose-jb/blob/612fab6099aa93a6f6d440350c905d948b6f5999/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt#L85>
listOf(
"debugApiElements-published",
"debugRuntimeElements-published",
"releaseApiElements-published",
"releaseRuntimeElements-published"
).forEach { variantNameToAlter ->
withVariant(variantNameToAlter) {
withDependencies {
removeAll { true } // remove androidx artifact with version
add("${id.group}:${id.name}") // add androidx artifact without version
}
}
}
}
}
}
}
}
eygraber
11/25/2022, 8:35 PMDima Avdeev
11/27/2022, 8:45 AM