Fix KotlinLibraryResolverImpl.kt on Windows

`absoluteFile` is not enough to make path unique. For example, it doesn't
expand things like '..' and 'IDEAPR~1' on Windows. `canonicalFile` seems
to solve the problem.
This commit is contained in:
Sergey Bogolepov
2021-08-03 19:13:07 +07:00
committed by Space
parent 3c3e51c6de
commit d5e2ac0efc
@@ -111,7 +111,7 @@ class KotlinLibraryResolverImpl<L: KotlinLibrary> internal constructor(
val result = KotlinLibraryResolverResultImpl(rootLibraries)
val cache = mutableMapOf<File, KotlinResolvedLibrary>()
cache.putAll(rootLibraries.map { it.library.libraryFile.absoluteFile to it })
cache.putAll(rootLibraries.map { it.library.libraryFile.canonicalFile to it })
var newDependencies = rootLibraries
do {
@@ -121,12 +121,12 @@ class KotlinLibraryResolverImpl<L: KotlinLibrary> internal constructor(
.filterNot { searchPathResolver.isProvidedByDefault(it) }
.mapNotNull { searchPathResolver.resolve(it)?.let(::KotlinResolvedLibraryImpl) }
.map { resolved ->
val absoluteFile = resolved.library.libraryFile.absoluteFile
if (absoluteFile in cache) {
library.addDependency(cache[absoluteFile]!!)
val canonicalFile = resolved.library.libraryFile.canonicalFile
if (canonicalFile in cache) {
library.addDependency(cache[canonicalFile]!!)
null
} else {
cache.put(absoluteFile, resolved)
cache.put(canonicalFile, resolved)
library.addDependency(resolved)
resolved
}