[KPM] Introduce separate IdeaKotlinDependencyCoordinates entity
This splits IdeaKotlinSourceCoordinates from the actual IdeaKotlinSourceDependency KT-51386
This commit is contained in:
committed by
Space
parent
588ea65d66
commit
0f8f61c373
+14
-3
@@ -54,7 +54,7 @@ public abstract class org/jetbrains/kotlin/gradle/kpm/KotlinMutableExternalModel
|
||||
public abstract fun set (Lorg/jetbrains/kotlin/gradle/kpm/KotlinExternalModelKey;Ljava/lang/Object;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinBinaryCoordinates : java/io/Serializable {
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinBinaryCoordinates : org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependencyCoordinates {
|
||||
public abstract fun getGroup ()Ljava/lang/String;
|
||||
public abstract fun getKotlinFragmentName ()Ljava/lang/String;
|
||||
public abstract fun getKotlinModuleName ()Ljava/lang/String;
|
||||
@@ -79,6 +79,7 @@ public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinD
|
||||
public static final field Companion Lorg/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependency$Companion;
|
||||
public static final field DOCUMENTATION_BINARY_TYPE Ljava/lang/String;
|
||||
public static final field SOURCES_BINARY_TYPE Ljava/lang/String;
|
||||
public abstract fun getCoordinates ()Lorg/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependencyCoordinates;
|
||||
public abstract fun getExternal ()Lorg/jetbrains/kotlin/gradle/kpm/KotlinExternalModelContainer;
|
||||
}
|
||||
|
||||
@@ -88,8 +89,11 @@ public final class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependency$Com
|
||||
public static final field SOURCES_BINARY_TYPE Ljava/lang/String;
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependencyCoordinates : java/io/Serializable {
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependencyKt {
|
||||
public static final fun getPath (Lorg/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinSourceDependency;)Ljava/lang/String;
|
||||
public static final fun getPath (Lorg/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinSourceCoordinates;)Ljava/lang/String;
|
||||
public static final fun isClasspathType (Lorg/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinResolvedBinaryDependency;)Z
|
||||
public static final fun isDocumentationType (Lorg/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinResolvedBinaryDependency;)Z
|
||||
public static final fun isSourcesType (Lorg/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinResolvedBinaryDependency;)Z
|
||||
@@ -198,7 +202,7 @@ public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinR
|
||||
public abstract fun getFile ()Ljava/io/File;
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinSourceDependency : org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependency {
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinSourceCoordinates : org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependencyCoordinates {
|
||||
public abstract fun getBuildId ()Ljava/lang/String;
|
||||
public abstract fun getKotlinFragmentName ()Ljava/lang/String;
|
||||
public abstract fun getKotlinModuleClassifier ()Ljava/lang/String;
|
||||
@@ -207,6 +211,13 @@ public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinS
|
||||
public abstract fun getProjectPath ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinSourceCoordinatesImpl$Companion {
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinSourceDependency : org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinDependency {
|
||||
public abstract fun getCoordinates ()Lorg/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinSourceCoordinates;
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/kpm/idea/IdeaKotlinSourceDirectory : java/io/Serializable {
|
||||
public abstract fun getFile ()Ljava/io/File;
|
||||
}
|
||||
|
||||
+31
-12
@@ -15,6 +15,7 @@ import java.io.File
|
||||
import java.io.Serializable
|
||||
|
||||
sealed interface IdeaKotlinDependency : Serializable {
|
||||
val coordinates: IdeaKotlinDependencyCoordinates?
|
||||
val external: KotlinExternalModelContainer
|
||||
|
||||
companion object {
|
||||
@@ -24,7 +25,9 @@ sealed interface IdeaKotlinDependency : Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface IdeaKotlinSourceDependency : IdeaKotlinDependency {
|
||||
sealed interface IdeaKotlinDependencyCoordinates : Serializable
|
||||
|
||||
sealed interface IdeaKotlinSourceCoordinates : IdeaKotlinDependencyCoordinates {
|
||||
val buildId: String
|
||||
val projectPath: String
|
||||
val projectName: String
|
||||
@@ -33,10 +36,11 @@ sealed interface IdeaKotlinSourceDependency : IdeaKotlinDependency {
|
||||
val kotlinFragmentName: String
|
||||
}
|
||||
|
||||
val IdeaKotlinSourceDependency.path: String
|
||||
get() = "${buildId.takeIf { it != ":" }.orEmpty()}$projectPath/$kotlinModuleName/$kotlinFragmentName"
|
||||
sealed interface IdeaKotlinSourceDependency : IdeaKotlinDependency {
|
||||
override val coordinates: IdeaKotlinSourceCoordinates
|
||||
}
|
||||
|
||||
sealed interface IdeaKotlinBinaryCoordinates : Serializable {
|
||||
sealed interface IdeaKotlinBinaryCoordinates : IdeaKotlinDependencyCoordinates {
|
||||
val group: String
|
||||
val module: String
|
||||
val version: String
|
||||
@@ -45,7 +49,7 @@ sealed interface IdeaKotlinBinaryCoordinates : Serializable {
|
||||
}
|
||||
|
||||
sealed interface IdeaKotlinBinaryDependency : IdeaKotlinDependency {
|
||||
val coordinates: IdeaKotlinBinaryCoordinates?
|
||||
override val coordinates: IdeaKotlinBinaryCoordinates?
|
||||
}
|
||||
|
||||
sealed interface IdeaKotlinUnresolvedBinaryDependency : IdeaKotlinBinaryDependency {
|
||||
@@ -63,17 +67,12 @@ val IdeaKotlinResolvedBinaryDependency.isClasspathType get() = binaryType == CLA
|
||||
|
||||
@InternalKotlinGradlePluginApi
|
||||
data class IdeaKotlinSourceDependencyImpl(
|
||||
override val buildId: String,
|
||||
override val projectPath: String,
|
||||
override val projectName: String,
|
||||
override val kotlinModuleName: String,
|
||||
override val kotlinModuleClassifier: String?,
|
||||
override val kotlinFragmentName: String,
|
||||
override val coordinates: IdeaKotlinSourceCoordinates,
|
||||
override val external: KotlinExternalModelContainer = KotlinExternalModelContainer.Empty
|
||||
) : IdeaKotlinSourceDependency {
|
||||
|
||||
override fun toString(): String {
|
||||
return "fragment: $path"
|
||||
return "source: $coordinates"
|
||||
}
|
||||
|
||||
@InternalKotlinGradlePluginApi
|
||||
@@ -102,6 +101,26 @@ data class IdeaKotlinBinaryCoordinatesImpl(
|
||||
}
|
||||
}
|
||||
|
||||
@InternalKotlinGradlePluginApi
|
||||
data class IdeaKotlinSourceCoordinatesImpl(
|
||||
override val buildId: String,
|
||||
override val projectPath: String,
|
||||
override val projectName: String,
|
||||
override val kotlinModuleName: String,
|
||||
override val kotlinModuleClassifier: String?,
|
||||
override val kotlinFragmentName: String
|
||||
) : IdeaKotlinSourceCoordinates {
|
||||
|
||||
override fun toString(): String = path
|
||||
|
||||
companion object {
|
||||
private const val serialVersionUID = 0L
|
||||
}
|
||||
}
|
||||
|
||||
val IdeaKotlinSourceCoordinates.path: String
|
||||
get() = "${buildId.takeIf { it != ":" }.orEmpty()}$projectPath/$kotlinModuleName/$kotlinFragmentName"
|
||||
|
||||
@InternalKotlinGradlePluginApi
|
||||
data class IdeaKotlinResolvedBinaryDependencyImpl(
|
||||
override val coordinates: IdeaKotlinBinaryCoordinates?,
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ interface IdeaKotlinSourceDependencyMatcher : IdeaKotlinDependencyMatcher<IdeaKo
|
||||
override val description: String = path
|
||||
|
||||
override fun matches(dependency: IdeaKotlinSourceDependency): Boolean {
|
||||
return path == dependency.path
|
||||
return path == dependency.coordinates.path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ interface IdeaKotlinSourceDependencyMatcher : IdeaKotlinDependencyMatcher<IdeaKo
|
||||
override val description: String = pathRegex.pattern
|
||||
|
||||
override fun matches(dependency: IdeaKotlinSourceDependency): Boolean {
|
||||
return pathRegex.matches(dependency.path)
|
||||
return pathRegex.matches(dependency.coordinates.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ fun IdeaKotlinFragment.assertSourceDependencies(matchers: Set<IdeaKotlinSourceDe
|
||||
appendLine()
|
||||
appendLine("${name}: Unexpected source dependency paths:")
|
||||
unexpectedDependencies.forEach { unexpectedDependency ->
|
||||
appendLine("\"${unexpectedDependency.path}\",")
|
||||
appendLine("\"${unexpectedDependency.coordinates.path}\",")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ fun IdeaKotlinFragment.assertSourceDependencies(matchers: Set<IdeaKotlinSourceDe
|
||||
appendLine()
|
||||
appendLine("${name}: Resolved source dependency paths:")
|
||||
sourceDependencies.forEach { dependency ->
|
||||
appendLine("\"${dependency.path}\",")
|
||||
appendLine("\"${dependency.coordinates.path}\",")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
+8
-6
@@ -27,12 +27,14 @@ internal class IdeaKotlinSourceDependencyResolver(
|
||||
val kotlinModuleIdentifier = resolution.dependency.toModuleDependency().moduleIdentifier
|
||||
return resolution.allVisibleSourceSetNames.map { visibleFragmentName ->
|
||||
IdeaKotlinSourceDependencyImpl(
|
||||
buildId = gradleProjectIdentifier.build.name,
|
||||
projectPath = gradleProjectIdentifier.projectPath,
|
||||
projectName = gradleProjectIdentifier.projectName,
|
||||
kotlinModuleName = kotlinModuleIdentifier.moduleName,
|
||||
kotlinModuleClassifier = kotlinModuleIdentifier.moduleClassifier,
|
||||
kotlinFragmentName = visibleFragmentName
|
||||
IdeaKotlinSourceCoordinatesImpl(
|
||||
buildId = gradleProjectIdentifier.build.name,
|
||||
projectPath = gradleProjectIdentifier.projectPath,
|
||||
projectName = gradleProjectIdentifier.projectName,
|
||||
kotlinModuleName = kotlinModuleIdentifier.moduleName,
|
||||
kotlinModuleClassifier = kotlinModuleIdentifier.moduleClassifier,
|
||||
kotlinFragmentName = visibleFragmentName
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user