JS search path resolver with attributes.

Warn on inclusion of klibs with the same name in manifest
This commit is contained in:
Alexander Gorshenev
2019-10-10 01:11:56 +03:00
committed by alexander-gorshenev
parent bc4be53569
commit 55805ddeb8
4 changed files with 166 additions and 39 deletions
@@ -39,6 +39,7 @@ class KotlinLibraryResolverImpl<L: KotlinLibrary>(
noEndorsedLibs: Boolean
) = findLibraries(unresolvedLibraries, noStdLib, noDefaultLibs, noEndorsedLibs)
.leaveDistinct()
.omitDuplicateNames()
.resolveDependencies()
/**
@@ -74,10 +75,24 @@ class KotlinLibraryResolverImpl<L: KotlinLibrary>(
groupedByAbsolutePath.map { it.value.first() }
}
/**
* Having two libraries with the same uniqName we only keep the first one.
* TODO: The old JS plugin passes libraries with the same uniqName twice,
* so make it a warning for now.
*/
private fun List<KotlinLibrary>.omitDuplicateNames() =
this.groupBy { it.uniqueName }.let { groupedByUniqName ->
warnOnLibraryDuplicateNames(groupedByUniqName.filter { it.value.size > 1 }.keys)
groupedByUniqName.map { it.value.first() }
}
private fun warnOnLibraryDuplicates(duplicatedPaths: Iterable<String>) {
duplicatedPaths.forEach { logger.warning("library included more than once: $it") }
}
private fun warnOnLibraryDuplicateNames(duplicatedPaths: Iterable<String>) {
duplicatedPaths.forEach { logger.warning("duplicate library name: $it") }
}
/**
* Given the list of root libraries does the following: