@@ -81,14 +81,33 @@ open class JetbrainsExtensions(
8181 fun KotlinNativeTarget.substituteForRedirectedPublishedDependencies () {
8282 val main = compilations.getByName(" main" )
8383 val test = compilations.getByName(" test" )
84- val kNativeManifestRedirectingModulesRaw =
85- project.property(" artifactRedirection.modulesForKNativeManifest" ) as String
8684
87- val projectPathToRedirectingVersionMap = kNativeManifestRedirectingModulesRaw
88- .split(" ," ).associate {
89- val pair = it.split(" =" )
90- pair[0 ] to project.property(pair[1 ]) as String
85+ val targetName = name.lowercase()
86+ // The target name in a dependency project might be different from this project,
87+ // so we check for an alternative name too.
88+ // Historically, we had such aliases only for the 'ios <-> uikit' pair.
89+ val altName = if (targetName.startsWith(" ios" )) {
90+ targetName.replace(" ios" , " uikit" )
91+ } else if (targetName.startsWith(" uikit" )) {
92+ targetName.replace(" uikit" , " ios" )
93+ } else {
94+ null
95+ }
96+
97+ val rootProjectName = project.rootProject.name // compose-multiplatform-core
98+
99+ val redirectedProjects = project.rootProject.subprojects.mapNotNull { project ->
100+ project.takeIf {
101+ // we are not interested in intermediate (structural) projects which are not published.
102+ // they have a group name with rootProjectName in it
103+ ! it.group.toString().contains(rootProjectName)
104+ }?.artifactRedirection()?.takeIf {
105+ it.targetNames.contains(targetName) || it.targetNames.contains(altName)
106+ }?.let {
107+ project.path to it.groupId + " :" + project.name + " :" + it.versionForTargetOrDefault(targetName)
91108 }
109+ }
110+
92111 listOf (main, test).flatMap {
93112 val configurations = it.configurations
94113 listOf (
@@ -102,11 +121,9 @@ open class JetbrainsExtensions(
102121 }.forEach { c ->
103122 c?.resolutionStrategy {
104123 it.dependencySubstitution {
105- projectPathToRedirectingVersionMap.forEach { path, version ->
106- val pathElements = path.split(" :" ).filter { it.isNotEmpty() }
107- val group = pathElements.dropLast(1 ).joinToString(" ." )
108- val module = pathElements.last()
109- val artifact = " androidx.$group :$module :$version "
124+ redirectedProjects.forEach { entry ->
125+ val path = entry.first
126+ val artifact = entry.second
110127 it.substitute(it.project(path)).using(it.module(artifact))
111128 }
112129 }
0 commit comments