mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
extracted checking for a new version into UpdateKobalt; semantics did not change
This commit is contained in:
parent
f199a8892e
commit
73b751f43f
2 changed files with 25 additions and 22 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.beust.kobalt.app
|
||||
|
||||
import com.beust.kobalt.misc.GithubApi
|
||||
import com.beust.kobalt.misc.KobaltWrapperProperties
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.misc.*
|
||||
import com.beust.kobalt.wrapper.Main
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeoutException
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
@ -21,4 +23,24 @@ public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapper
|
|||
fun downloadKobalt() {
|
||||
Main.main(arrayOf("--download", "--no-launch"))
|
||||
}
|
||||
|
||||
fun checkForNewVersion(latestVersionString: String) {
|
||||
try {
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue