From a6961385ccf0dee7b6d31e3f73d2c8ef91005f1a Mon Sep 17 00:00:00 2001 From: Oleksandr Karpovich Date: Fri, 17 May 2024 17:53:06 +0200 Subject: [PATCH] CfW: rely on exact configuration names to find the dependencies (#4828) --- .../web/internal/configureWebApplication.kt | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/web/internal/configureWebApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/web/internal/configureWebApplication.kt index 4306a199b5..2c163824fc 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/web/internal/configureWebApplication.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/web/internal/configureWebApplication.kt @@ -9,6 +9,7 @@ import org.gradle.api.Project import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.ResolvedDependency import org.gradle.api.artifacts.UnresolvedDependency +import org.gradle.api.artifacts.component.ModuleComponentIdentifier import org.gradle.api.provider.Provider import org.jetbrains.compose.ComposeBuildConfig import org.jetbrains.compose.ComposeExtension @@ -27,20 +28,23 @@ internal fun Project.configureWeb( // here we check all dependencies (including transitive) // If there is compose.ui, then skiko is required! val shouldRunUnpackSkiko = project.provider { - var dependsOnComposeUi = false - project.configurations.matching { configuration -> - val isWasmOrJs = configuration.name.contains("js", true) || - configuration.name.contains("wasm", true) - - configuration.isCanBeResolved && isWasmOrJs - }.all { configuration -> - val match = configuration.incoming.artifacts.resolvedArtifacts.get().any { artifact -> - artifact.id.componentIdentifier.toString().contains("org.jetbrains.compose.ui:ui:") + webExt.targetsToConfigure(project).any { target -> + val compilation = target.compilations.getByName("main") + val compileConfiguration = compilation.compileDependencyConfigurationName + val runtimeConfiguration = compilation.runtimeDependencyConfigurationName + + listOf(compileConfiguration, runtimeConfiguration).mapNotNull { name -> + project.configurations.findByName(name) + }.flatMap { configuration -> + configuration.incoming.resolutionResult.allComponents.map { it.id } + }.any { identifier -> + if (identifier is ModuleComponentIdentifier) { + identifier.group == "org.jetbrains.compose.ui" && identifier.module == "ui" + } else { + false + } } - - dependsOnComposeUi = dependsOnComposeUi || match } - dependsOnComposeUi } // configure only if there is k/wasm or k/js target: