1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

replaced Timestamp with Instant

This commit is contained in:
voddan 2016-01-29 12:08:57 +03:00
parent 934db829dc
commit 0fe76cd31d
2 changed files with 8 additions and 8 deletions

View file

@ -4,7 +4,7 @@ import com.beust.kobalt.api.Kobalt
import com.google.inject.Inject
import java.io.File
import java.io.FileReader
import java.sql.Timestamp
import java.time.Instant
import java.util.*
/**
@ -17,7 +17,7 @@ class KobaltWrapperProperties @Inject constructor() {
private val PROPERTY_VERSION_LAST_CHECKED = "kobalt.version.last_checked"
private val PROPERTY_DOWNLOAD_URL = "kobalt.downloadUrl"
fun create(version: String, versionLastChecked: Timestamp) {
fun create(version: String, versionLastChecked: Instant) {
log(2, "Creating $file with $version and ${defaultUrlFor(version)}")
KFiles.saveFile(file, listOf(
"$PROPERTY_VERSION=$version",
@ -36,7 +36,7 @@ class KobaltWrapperProperties @Inject constructor() {
get() {
val config = file
if (!config.exists()) {
create(Kobalt.version, Timestamp(0))
create(Kobalt.version, Instant.MIN)
}
val result = Properties()
@ -47,8 +47,8 @@ class KobaltWrapperProperties @Inject constructor() {
val version : String
get() = properties.getProperty(PROPERTY_VERSION)
val versionLastChecked: Timestamp
get() = Timestamp.valueOf(properties.getProperty(PROPERTY_VERSION_LAST_CHECKED))
val versionLastChecked: Instant
get() = Instant.parse(properties.getProperty(PROPERTY_VERSION_LAST_CHECKED))
val downloadUrl : String
get() = properties.getProperty(PROPERTY_DOWNLOAD_URL)

View file

@ -4,7 +4,7 @@ import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.misc.*
import com.beust.kobalt.wrapper.Main
import java.io.File
import java.sql.Timestamp
import java.time.Instant
import java.util.concurrent.TimeoutException
import javax.inject.Inject
@ -14,7 +14,7 @@ import javax.inject.Inject
public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapperProperties: KobaltWrapperProperties) {
fun updateKobalt() {
val newVersion = github.latestKobaltVersion
wrapperProperties.create(newVersion.get(), Timestamp(System.currentTimeMillis()))
wrapperProperties.create(newVersion.get(), Instant.now())
Main.main(arrayOf())
}
@ -40,7 +40,7 @@ public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapper
}
}
}
wrapperProperties.create(wrapperProperties.version, Timestamp(System.currentTimeMillis()))
wrapperProperties.create(wrapperProperties.version, Instant.now())
} catch(ex: TimeoutException) {
log(2, "Didn't get the new version in time, skipping it")
}