mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
replaced wrapperProperties.versionLastChecked
with versio with VersionCheckTimestampFile
This commit is contained in:
parent
f1b420849d
commit
18bf0e494a
2 changed files with 8 additions and 12 deletions
|
@ -4,7 +4,6 @@ import com.beust.kobalt.api.Kobalt
|
||||||
import com.google.inject.Inject
|
import com.google.inject.Inject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileReader
|
import java.io.FileReader
|
||||||
import java.time.Instant
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,14 +13,12 @@ class KobaltWrapperProperties @Inject constructor() {
|
||||||
private val WRAPPER_DIR = KFiles.KOBALT_DIR + "/wrapper"
|
private val WRAPPER_DIR = KFiles.KOBALT_DIR + "/wrapper"
|
||||||
private val KOBALT_WRAPPER_PROPERTIES = "kobalt-wrapper.properties"
|
private val KOBALT_WRAPPER_PROPERTIES = "kobalt-wrapper.properties"
|
||||||
private val PROPERTY_VERSION = "kobalt.version"
|
private val PROPERTY_VERSION = "kobalt.version"
|
||||||
private val PROPERTY_VERSION_LAST_CHECKED = "kobalt.version.last_checked"
|
|
||||||
private val PROPERTY_DOWNLOAD_URL = "kobalt.downloadUrl"
|
private val PROPERTY_DOWNLOAD_URL = "kobalt.downloadUrl"
|
||||||
|
|
||||||
fun create(version: String, versionLastChecked: Instant) {
|
fun create(version: String) {
|
||||||
log(2, "Creating $file with $version and ${defaultUrlFor(version)}")
|
log(2, "Creating $file with $version and ${defaultUrlFor(version)}")
|
||||||
KFiles.saveFile(file, listOf(
|
KFiles.saveFile(file, listOf(
|
||||||
"$PROPERTY_VERSION=$version",
|
"$PROPERTY_VERSION=$version"
|
||||||
"$PROPERTY_VERSION_LAST_CHECKED=$versionLastChecked"
|
|
||||||
// "$PROPERTY_DOWNLOAD_URL=${defaultUrlFor(version)}"
|
// "$PROPERTY_DOWNLOAD_URL=${defaultUrlFor(version)}"
|
||||||
).joinToString("\n"))
|
).joinToString("\n"))
|
||||||
}
|
}
|
||||||
|
@ -36,7 +33,7 @@ class KobaltWrapperProperties @Inject constructor() {
|
||||||
get() {
|
get() {
|
||||||
val config = file
|
val config = file
|
||||||
if (!config.exists()) {
|
if (!config.exists()) {
|
||||||
create(Kobalt.version, Instant.MIN)
|
create(Kobalt.version)
|
||||||
}
|
}
|
||||||
|
|
||||||
val result = Properties()
|
val result = Properties()
|
||||||
|
@ -47,9 +44,6 @@ class KobaltWrapperProperties @Inject constructor() {
|
||||||
val version : String
|
val version : String
|
||||||
get() = properties.getProperty(PROPERTY_VERSION)
|
get() = properties.getProperty(PROPERTY_VERSION)
|
||||||
|
|
||||||
val versionLastChecked: Instant
|
|
||||||
get() = Instant.parse(properties.getProperty(PROPERTY_VERSION_LAST_CHECKED))
|
|
||||||
|
|
||||||
val downloadUrl : String
|
val downloadUrl : String
|
||||||
get() = properties.getProperty(PROPERTY_DOWNLOAD_URL)
|
get() = properties.getProperty(PROPERTY_DOWNLOAD_URL)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.beust.kobalt.app
|
package com.beust.kobalt.app
|
||||||
|
|
||||||
import com.beust.kobalt.api.Kobalt
|
import com.beust.kobalt.api.Kobalt
|
||||||
|
import com.beust.kobalt.internal.build.VersionCheckTimestampFile
|
||||||
import com.beust.kobalt.misc.*
|
import com.beust.kobalt.misc.*
|
||||||
import com.beust.kobalt.wrapper.Main
|
import com.beust.kobalt.wrapper.Main
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -16,7 +17,8 @@ import javax.inject.Inject
|
||||||
public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapperProperties: KobaltWrapperProperties) {
|
public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapperProperties: KobaltWrapperProperties) {
|
||||||
fun updateKobalt() {
|
fun updateKobalt() {
|
||||||
val newVersion = github.latestKobaltVersion
|
val newVersion = github.latestKobaltVersion
|
||||||
wrapperProperties.create(newVersion.get(), Instant.now())
|
wrapperProperties.create(newVersion.get())
|
||||||
|
VersionCheckTimestampFile.updateTimestamp(Instant.now())
|
||||||
Main.main(arrayOf())
|
Main.main(arrayOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapper
|
||||||
* */
|
* */
|
||||||
fun checkForNewVersion(latestVersionFuture: Future<String>) {
|
fun checkForNewVersion(latestVersionFuture: Future<String>) {
|
||||||
if(Kobalt.versionCheckTimeout
|
if(Kobalt.versionCheckTimeout
|
||||||
> Duration.between(wrapperProperties.versionLastChecked, Instant.now()))
|
> Duration.between(VersionCheckTimestampFile.getTimestamp(), Instant.now()))
|
||||||
return // waits `Kobalt.versionCheckTimeout` before the next check
|
return // waits `Kobalt.versionCheckTimeout` before the next check
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -50,7 +52,7 @@ public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wrapperProperties.create(wrapperProperties.version, Instant.now())
|
VersionCheckTimestampFile.updateTimestamp(Instant.now())
|
||||||
} catch(ex: TimeoutException) {
|
} catch(ex: TimeoutException) {
|
||||||
log(2, "Didn't get the new version in time, skipping it")
|
log(2, "Didn't get the new version in time, skipping it")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue