Skip to content

Commit 478542b

Browse files
committed
CfW: rely on exact configuration names to find the dependencies (#4828)
(cherry picked from commit a696138)
1 parent ce89665 commit 478542b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/web/internal/configureWebApplication.kt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import org.gradle.api.Project
99
import org.gradle.api.artifacts.Configuration
1010
import org.gradle.api.artifacts.ResolvedDependency
1111
import org.gradle.api.artifacts.UnresolvedDependency
12+
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
1213
import org.gradle.api.provider.Provider
1314
import org.jetbrains.compose.ComposeBuildConfig
1415
import org.jetbrains.compose.ComposeExtension
@@ -27,20 +28,23 @@ internal fun Project.configureWeb(
2728
// here we check all dependencies (including transitive)
2829
// If there is compose.ui, then skiko is required!
2930
val shouldRunUnpackSkiko = project.provider {
30-
var dependsOnComposeUi = false
31-
project.configurations.matching { configuration ->
32-
val isWasmOrJs = configuration.name.contains("js", true) ||
33-
configuration.name.contains("wasm", true)
34-
35-
configuration.isCanBeResolved && isWasmOrJs
36-
}.all { configuration ->
37-
val match = configuration.incoming.artifacts.resolvedArtifacts.get().any { artifact ->
38-
artifact.id.componentIdentifier.toString().contains("org.jetbrains.compose.ui:ui:")
31+
webExt.targetsToConfigure(project).any { target ->
32+
val compilation = target.compilations.getByName("main")
33+
val compileConfiguration = compilation.compileDependencyConfigurationName
34+
val runtimeConfiguration = compilation.runtimeDependencyConfigurationName
35+
36+
listOf(compileConfiguration, runtimeConfiguration).mapNotNull { name ->
37+
project.configurations.findByName(name)
38+
}.flatMap { configuration ->
39+
configuration.incoming.resolutionResult.allComponents.map { it.id }
40+
}.any { identifier ->
41+
if (identifier is ModuleComponentIdentifier) {
42+
identifier.group == "org.jetbrains.compose.ui" && identifier.module == "ui"
43+
} else {
44+
false
45+
}
3946
}
40-
41-
dependsOnComposeUi = dependsOnComposeUi || match
4247
}
43-
dependsOnComposeUi
4448
}
4549

4650
// configure only if there is k/wasm or k/js target:

0 commit comments

Comments
 (0)