Configuration: Clean library version before adding it as dependency

#KT-25633 Fixed
This commit is contained in:
Alexey Sedunov
2018-08-02 21:02:24 +03:00
parent a8f8ecc012
commit db556d6551
2 changed files with 22 additions and 4 deletions
@@ -81,3 +81,21 @@ fun getRuntimeLibraryVersion(module: Module): String? {
val versions = getRuntimeLibraryVersions(module, null, targetPlatform ?: TargetPlatformKind.DEFAULT_PLATFORM)
return versions.toSet().singleOrNull()
}
fun getCleanRuntimeLibraryVersion(module: Module) = getRuntimeLibraryVersion(module)?.cleanUpVersion()
private fun String.cleanUpVersion(): String {
return StringBuilder(this)
.apply {
val parIndex = indexOf("(")
if (parIndex >= 0) {
delete(parIndex, length)
}
val releaseIndex = indexOf("-release-")
if (releaseIndex >= 0) {
delete(releaseIndex, length)
}
}
.toString()
.trim()
}