compose-multiplatform: Adding any compose dependency breaks resolving the Gradle configuration
When I am adding the compose dependency to a (resolvable) Gradle configuration (includeImplementation
is my custom configuration) as follows:
includeImplementation(compose.desktop.currentOs) // same with common
and then trying to resolve the dependencies of this configuration
includeImplementation.resolvedConfiguration.firstLevelModuleDependencies
I am getting the following error
Caused by: org.gradle.internal.component.AmbiguousConfigurationSelectionException: Cannot choose between the following variants of org.jetbrains.compose.foundation:foundation:1.0.0-beta5:
- debugRuntimeElements-published
- desktopRuntimeElements-published
- releaseRuntimeElements-published
My custom configuration above is one example, but there are other scenarios where you have to use custom configurations from third-party Gradle plugins, and therefore using this together with Compose does not work.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 20 (7 by maintainers)
Related issue: https://github.com/JetBrains/skiko/issues/547
Generally speaking, the issue here is not if one uses the Kotlin Multiplatform plugin or not, but that Gradle does not have enough information about which artifact it should use.
To fix this, the Compose Gradle plugin should ask for the correct UI attribute. For this to work correctly, I think skiko has to provide the correct attributes with each artifact first. Also, skiko should add a namespace to the ui attribute - I also added that to the skiko issue.
Temporary fix
I found out that you can apparently “fix” this by using some weird Gradle behaviour, and ask for an ui attribute that does not even exist. Let’s use
awt
, just because it makes sense in this case.To apply this fix, do this, either using
configurations.all
or just for your configuration which you use to shade or include dependencies: