Kotlin Facet: Fix platform detection in android-gradle projects

Sort candidate library names by descending length.
Suppress common library if platform-specific one is also present

 #KT-16827 Fixed
This commit is contained in:
Alexey Sedunov
2017-03-29 17:25:49 +03:00
parent 7a53b2f4c8
commit a8a9c3bbf4
4 changed files with 15 additions and 4 deletions
@@ -44,7 +44,10 @@ class PlatformAndroidGradleDetector : KotlinPlatformGradleDetector {
.flatMap { it.data.jarLibraryDependencies.asSequence() }
.forEach {
val libraryName = it.name
if (libraryName.substringBeforeLast("-") in libraryIds) return libraryName.substringAfterLast("-")
for (libraryId in libraryIds) {
val prefix = "$libraryId-"
if (libraryName.startsWith(prefix)) return libraryName.substringAfter(prefix)
}
}
return null
}