@@ -81,33 +81,14 @@ 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
8486
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)
87+ val projectPathToRedirectingVersionMap = kNativeManifestRedirectingModulesRaw
88+ .split(" ," ).associate {
89+ val pair = it.split(" =" )
90+ pair[0 ] to project.property(pair[1 ]) as String
10891 }
109- }
110-
11192 listOf (main, test).flatMap {
11293 val configurations = it.configurations
11394 listOf (
@@ -121,9 +102,11 @@ open class JetbrainsExtensions(
121102 }.forEach { c ->
122103 c?.resolutionStrategy {
123104 it.dependencySubstitution {
124- redirectedProjects.forEach { entry ->
125- val path = entry.first
126- val artifact = entry.second
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 "
127110 it.substitute(it.project(path)).using(it.module(artifact))
128111 }
129112 }
0 commit comments