[Gradle] Ide Dependency Resolution: Provide capabilities for binary coordinates

^KT-60053 Verification Pending
This commit is contained in:
Sebastian Sellmair
2023-07-10 20:20:52 +02:00
committed by Space Team
parent 7af254fbf2
commit 041b424bab
11 changed files with 148 additions and 16 deletions
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.gradle.idea.testFixtures.tcs
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinDependency
import kotlin.test.fail
fun Iterable<IdeaKotlinDependency>.assertMatches(vararg notation: Any?): Iterable<IdeaKotlinDependency> {
fun <T : IdeaKotlinDependency> Iterable<T>.assertMatches(vararg notation: Any?): Iterable<T> {
val thisList = toList()
val matchers = notation.flatMap { buildIdeaKotlinDependencyMatchers(it) }
@@ -51,3 +51,10 @@ fun Iterable<IdeaKotlinDependency>.assertMatches(vararg notation: Any?): Iterabl
}
)
}
fun <T : IdeaKotlinDependency> Iterable<T>.getOrFail(matcher: IdeaKotlinDependencyMatcher): T {
val candidates = filter { matcher.matches(it) }
if (candidates.isEmpty()) fail("No dependency matching '$matcher' found")
if (candidates.size > 1) fail("Multiple dependencies matching '$matcher' found: ${candidates.map { it.coordinates }}")
return candidates.single()
}