Escape resolving same library several times in K/N (#3880)
This commit is contained in:
@@ -132,22 +132,28 @@ abstract class KotlinLibrarySearchPathResolver<L : KotlinLibrary>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resolve(unresolved: UnresolvedLibrary, isDefaultLink: Boolean): L {
|
// Default libraries could be resolved several times during findLibraries and resolveDependencies.
|
||||||
val givenPath = unresolved.path
|
// Store already resolved libraries.
|
||||||
try {
|
private val resolvedLibraries = HashMap<UnresolvedLibrary, L>()
|
||||||
val fileSequence = resolutionSequence(givenPath)
|
|
||||||
val matching = fileSequence
|
|
||||||
.filterOutPre_1_4_libraries()
|
|
||||||
.flatMap { libraryComponentBuilder(it, isDefaultLink).asSequence() }
|
|
||||||
.map { it.takeIf { libraryMatch(it, unresolved) } }
|
|
||||||
.filterNotNull()
|
|
||||||
|
|
||||||
return matching.firstOrNull() ?: run {
|
override fun resolve(unresolved: UnresolvedLibrary, isDefaultLink: Boolean): L {
|
||||||
logger.fatal("Could not find \"$givenPath\" in ${searchRoots.map { it.absolutePath }}.")
|
return resolvedLibraries.getOrPut(unresolved) {
|
||||||
|
val givenPath = unresolved.path
|
||||||
|
try {
|
||||||
|
val fileSequence = resolutionSequence(givenPath)
|
||||||
|
val matching = fileSequence
|
||||||
|
.filterOutPre_1_4_libraries()
|
||||||
|
.flatMap { libraryComponentBuilder(it, isDefaultLink).asSequence() }
|
||||||
|
.map { it.takeIf { libraryMatch(it, unresolved) } }
|
||||||
|
.filterNotNull()
|
||||||
|
|
||||||
|
matching.firstOrNull() ?: run {
|
||||||
|
logger.fatal("Could not find \"$givenPath\" in ${searchRoots.map { it.absolutePath }}.")
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
logger.error("Failed to resolve Kotlin library: $givenPath")
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
|
||||||
logger.error("Failed to resolve Kotlin library: $givenPath")
|
|
||||||
throw e
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user