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 result = KotlinLibraryResolverResultImpl(rootLibraries)
val cache = mutableMapOf<File, KotlinResolvedLibrary>() 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 var newDependencies = rootLibraries
do { do {
@@ -121,12 +121,12 @@ class KotlinLibraryResolverImpl<L: KotlinLibrary> internal constructor(
.filterNot { searchPathResolver.isProvidedByDefault(it) } .filterNot { searchPathResolver.isProvidedByDefault(it) }
.mapNotNull { searchPathResolver.resolve(it)?.let(::KotlinResolvedLibraryImpl) } .mapNotNull { searchPathResolver.resolve(it)?.let(::KotlinResolvedLibraryImpl) }
.map { resolved -> .map { resolved ->
val absoluteFile = resolved.library.libraryFile.absoluteFile val canonicalFile = resolved.library.libraryFile.canonicalFile
if (absoluteFile in cache) { if (canonicalFile in cache) {
library.addDependency(cache[absoluteFile]!!) library.addDependency(cache[canonicalFile]!!)
null null
} else { } else {
cache.put(absoluteFile, resolved) cache.put(canonicalFile, resolved)
library.addDependency(resolved) library.addDependency(resolved)
resolved resolved
} }