[Gradle] Constraint IdeVisibleMultiplatformSourceDependencyResolver to non-leaf source sets
^KT-55112 Verification Pending
This commit is contained in:
committed by
Space Team
parent
2f5dc93ba7
commit
d6f9e62565
+9
-3
@@ -9,6 +9,7 @@ package org.jetbrains.kotlin.gradle.plugin.ide
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.ExternalKotlinTargetApi
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||
import org.jetbrains.kotlin.gradle.idea.serialize.IdeaKotlinExtrasSerializationExtension
|
||||
import org.jetbrains.kotlin.gradle.idea.serialize.IdeaKotlinExtrasSerializationExtensionBuilder
|
||||
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinDependency
|
||||
@@ -19,8 +20,8 @@ import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
||||
import org.jetbrains.kotlin.gradle.plugin.ide.IdeMultiplatformImport.DependencyResolutionLevel.Default
|
||||
import org.jetbrains.kotlin.gradle.plugin.ide.IdeMultiplatformImport.DependencyResolutionLevel.Overwrite
|
||||
import org.jetbrains.kotlin.gradle.plugin.ide.IdeMultiplatformImport.SourceSetConstraint
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.project
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.isNativeSourceSet
|
||||
import org.jetbrains.kotlin.gradle.utils.getOrPut
|
||||
import org.jetbrains.kotlin.tooling.core.Extras
|
||||
@@ -139,9 +140,14 @@ interface IdeMultiplatformImport {
|
||||
|
||||
companion object {
|
||||
val unconstrained = SourceSetConstraint { true }
|
||||
|
||||
val isNative = SourceSetConstraint { sourceSet -> isNativeSourceSet(sourceSet) }
|
||||
val isMetadata = SourceSetConstraint { sourceSet -> sourceSet.internal.compilations.any { it is KotlinMetadataCompilation } }
|
||||
val isPlatform = !isMetadata and SourceSetConstraint { sourceSet -> sourceSet.internal.compilations.any() }
|
||||
|
||||
val isLeaf = SourceSetConstraint { sourceSet ->
|
||||
(sourceSet.project.multiplatformExtensionOrNull ?: return@SourceSetConstraint true).sourceSets
|
||||
.none { otherSourceSet -> sourceSet in otherSourceSet.dependsOn }
|
||||
}
|
||||
|
||||
val isJvmAndAndroid = SourceSetConstraint { sourceSet ->
|
||||
sourceSet.internal.compilations.map { it.platformType }.toSet() == setOf(jvm, androidJvm)
|
||||
}
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ fun IdeMultiplatformImport(extension: KotlinMultiplatformExtension): IdeMultipla
|
||||
|
||||
registerDependencyResolver(
|
||||
resolver = IdeVisibleMultiplatformSourceDependencyResolver,
|
||||
constraint = SourceSetConstraint.unconstrained,
|
||||
constraint = !SourceSetConstraint.isLeaf,
|
||||
phase = IdeMultiplatformImport.DependencyResolutionPhase.SourceDependencyResolution,
|
||||
level = IdeMultiplatformImport.DependencyResolutionLevel.Default
|
||||
)
|
||||
@@ -46,21 +46,21 @@ fun IdeMultiplatformImport(extension: KotlinMultiplatformExtension): IdeMultipla
|
||||
|
||||
registerDependencyResolver(
|
||||
resolver = IdeTransformedMetadataDependencyResolver,
|
||||
constraint = SourceSetConstraint.isMetadata,
|
||||
constraint = !SourceSetConstraint.isLeaf,
|
||||
phase = IdeMultiplatformImport.DependencyResolutionPhase.BinaryDependencyResolution,
|
||||
level = IdeMultiplatformImport.DependencyResolutionLevel.Default
|
||||
)
|
||||
|
||||
registerDependencyResolver(
|
||||
resolver = IdeOriginalMetadataDependencyResolver,
|
||||
constraint = SourceSetConstraint.isMetadata,
|
||||
constraint = !SourceSetConstraint.isLeaf,
|
||||
phase = IdeMultiplatformImport.DependencyResolutionPhase.BinaryDependencyResolution,
|
||||
level = IdeMultiplatformImport.DependencyResolutionLevel.Default,
|
||||
)
|
||||
|
||||
registerDependencyResolver(
|
||||
resolver = IdePlatformDependencyResolver(),
|
||||
constraint = SourceSetConstraint.isPlatform,
|
||||
constraint = SourceSetConstraint.isLeaf,
|
||||
phase = IdeMultiplatformImport.DependencyResolutionPhase.BinaryDependencyResolution,
|
||||
level = IdeMultiplatformImport.DependencyResolutionLevel.Default
|
||||
)
|
||||
|
||||
-12
@@ -95,9 +95,6 @@ class IdeResolveSourceDependenciesTest {
|
||||
)
|
||||
|
||||
consumer.resolveDependencies("linuxX64Main").assertMatches(
|
||||
regularSourceDependency(":producer/commonMain"),
|
||||
regularSourceDependency(":producer/nativeMain"),
|
||||
regularSourceDependency(":producer/linuxMain"),
|
||||
dependsOnDependency(":consumer/commonMain"),
|
||||
dependsOnDependency(":consumer/nativeMain"),
|
||||
dependsOnDependency(":consumer/linuxMain"),
|
||||
@@ -105,9 +102,6 @@ class IdeResolveSourceDependenciesTest {
|
||||
)
|
||||
|
||||
consumer.resolveDependencies("linuxX64Test").assertMatches(
|
||||
regularSourceDependency(":producer/commonMain"),
|
||||
regularSourceDependency(":producer/nativeMain"),
|
||||
regularSourceDependency(":producer/linuxMain"),
|
||||
friendSourceDependency(":consumer/commonMain"),
|
||||
friendSourceDependency(":consumer/nativeMain"),
|
||||
friendSourceDependency(":consumer/linuxMain"),
|
||||
@@ -119,9 +113,6 @@ class IdeResolveSourceDependenciesTest {
|
||||
)
|
||||
|
||||
consumer.resolveDependencies("linuxArm64Main").assertMatches(
|
||||
regularSourceDependency(":producer/commonMain"),
|
||||
regularSourceDependency(":producer/nativeMain"),
|
||||
regularSourceDependency(":producer/linuxMain"),
|
||||
dependsOnDependency(":consumer/commonMain"),
|
||||
dependsOnDependency(":consumer/nativeMain"),
|
||||
dependsOnDependency(":consumer/linuxMain"),
|
||||
@@ -129,9 +120,6 @@ class IdeResolveSourceDependenciesTest {
|
||||
)
|
||||
|
||||
consumer.resolveDependencies("linuxArm64Test").assertMatches(
|
||||
regularSourceDependency(":producer/commonMain"),
|
||||
regularSourceDependency(":producer/nativeMain"),
|
||||
regularSourceDependency(":producer/linuxMain"),
|
||||
friendSourceDependency(":consumer/commonMain"),
|
||||
friendSourceDependency(":consumer/nativeMain"),
|
||||
friendSourceDependency(":consumer/linuxMain"),
|
||||
|
||||
Reference in New Issue
Block a user