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

autoUpdate setting.

This commit is contained in:
Cedric Beust 2017-03-30 10:13:41 -07:00
parent 0178500bf8
commit b3efc12569
2 changed files with 15 additions and 2 deletions

View file

@ -42,6 +42,9 @@ class KobaltSettingsXml {
@XmlElement(name = "kobaltCompilerSeparateProcess") @JvmField @XmlElement(name = "kobaltCompilerSeparateProcess") @JvmField
var kobaltCompilerSeparateProcess: Boolean = false var kobaltCompilerSeparateProcess: Boolean = false
@XmlElement(name = "autoUpdate") @JvmField
var autoUpdate: Boolean = false
} }
class ProxiesXml { class ProxiesXml {
@ -85,6 +88,11 @@ class KobaltSettings @Inject constructor(val xmlFile: KobaltSettingsXml) {
*/ */
val localMavenRepo = KFiles.makeDir(xmlFile.localMavenRepo) val localMavenRepo = KFiles.makeDir(xmlFile.localMavenRepo)
/**
* If true, Kobalt will automatically update itself if a new version is found.
*/
val autoUpdate = xmlFile.autoUpdate
/** /**
* If true, the Kotlin compiler will always be launched in a separate JVM, even if the requested * If true, the Kotlin compiler will always be launched in a separate JVM, even if the requested
* version is the same as the internal version. * version is the same as the internal version.

View file

@ -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.KobaltSettings
import com.beust.kobalt.internal.build.VersionCheckTimestampFile 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
@ -14,7 +15,8 @@ import javax.inject.Inject
/** /**
* Update Kobalt to the latest version. * Update Kobalt to the latest version.
*/ */
class UpdateKobalt @Inject constructor(val github: GithubApi2, val wrapperProperties: KobaltWrapperProperties) { class UpdateKobalt @Inject constructor(val github: GithubApi2, val wrapperProperties: KobaltWrapperProperties,
val settings: KobaltSettings, val updateKobalt: UpdateKobalt) {
fun updateKobalt() { fun updateKobalt() {
val newVersion = github.latestKobaltVersion val newVersion = github.latestKobaltVersion
wrapperProperties.create(newVersion.get()) wrapperProperties.create(newVersion.get())
@ -43,7 +45,10 @@ class UpdateKobalt @Inject constructor(val github: GithubApi2, val wrapperProper
val current = StringVersion(Kobalt.version) val current = StringVersion(Kobalt.version)
val distFile = File(KFiles.distributionsDir) val distFile = File(KFiles.distributionsDir)
if (latestVersion > current) { if (latestVersion > current) {
if (distFile.exists()) { if (settings.autoUpdate) {
kobaltLog(1, "**** Automatically updating to $latestVersionString")
updateKobalt.updateKobalt()
} else if (distFile.exists()) {
kobaltLog(1, "**** Version $latestVersionString is installed, you can switch to it with " + kobaltLog(1, "**** Version $latestVersionString is installed, you can switch to it with " +
"./kobaltw --update") "./kobaltw --update")
} else { } else {