Fix cuiCloud

This commit is contained in:
Him188 2020-05-06 14:00:32 +08:00
parent d80ab1608a
commit e69037e10f

View File

@ -139,17 +139,20 @@ subprojects {
} }
fun Project.findLatestFile(): Map.Entry<String, File>? { fun Project.findLatestFile(): Map.Entry<String, File> {
return File(projectDir, "build/libs").walk() return File(projectDir, "build/libs").walk()
.filter { it.isFile } .filter { it.isFile }
.onEach { println("all files=$it") } .onEach { println("all files=$it") }
.filter { it.name.matches(Regex("""${project.name}-([0-9]|\.)*\.jar""")) } .filter { it.name.matches(Regex("""${project.name}-[0-9][0-9]*(\.[0-9]*)*.*\.jar""")) }
.onEach { println("matched file: ${it.name}") } .onEach { println("matched file: ${it.name}") }
.associateBy { it.nameWithoutExtension.substringAfterLast('-') } .associateBy { it.nameWithoutExtension.substringAfterLast('-') }
.onEach { println("versions: $it") } .onEach { println("versions: $it") }
.maxBy { .maxBy { (version, file) ->
it.key.split('.').foldRightIndexed(0) { index: Int, s: String, acc: Int -> version.split('.').let {
acc + 100.0.pow(2 - index).toInt() * (s.toIntOrNull() ?: 0) if (it.size == 2) it + "0"
else it
}.reversed().foldIndexed(0) { index: Int, acc: Int, s: String ->
acc + 100.0.pow(index).toInt() * (s.toIntOrNull() ?: 0)
} }
} } ?: error("cannot find any file to upload")
} }