1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-29 17:38:12 -07:00

extracted checking for a new version into UpdateKobalt; semantics did not change

This commit is contained in:
voddan 2016-01-29 11:04:12 +03:00
parent f199a8892e
commit 73b751f43f
2 changed files with 25 additions and 22 deletions

View file

@ -22,8 +22,6 @@ import com.google.inject.Guice
import java.io.File
import java.nio.file.Paths
import java.util.*
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
import javax.inject.Inject
public fun main(argv: Array<String>) {
@ -98,24 +96,7 @@ private class Main @Inject constructor(
log(1, if (result != 0) "BUILD FAILED: $result" else "BUILD SUCCESSFUL ($seconds seconds)")
// Check for new version
try {
val latestVersionString = latestVersionFuture.get(1, TimeUnit.SECONDS)
val latestVersion = Versions.toLongVersion(latestVersionString)
val current = Versions.toLongVersion(Kobalt.version)
val distFile = File(KFiles.joinDir(KFiles.distributionsDir, latestVersionString))
if (latestVersion > current) {
if (distFile.exists()) {
log(1, "**** Version $latestVersionString is installed")
} else {
listOf("", "New Kobalt version available: $latestVersionString",
"To update, run ./kobaltw --update", "").forEach {
log(1, "**** $it")
}
}
}
} catch(ex: TimeoutException) {
log(2, "Didn't get the new version in time, skipping it")
}
updateKobalt.checkForNewVersion(latestVersionFuture.get())
}
return result
}