mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -07:00
autoUpdate setting.
This commit is contained in:
parent
0178500bf8
commit
b3efc12569
2 changed files with 15 additions and 2 deletions
|
@ -42,6 +42,9 @@ class KobaltSettingsXml {
|
|||
|
||||
@XmlElement(name = "kobaltCompilerSeparateProcess") @JvmField
|
||||
var kobaltCompilerSeparateProcess: Boolean = false
|
||||
|
||||
@XmlElement(name = "autoUpdate") @JvmField
|
||||
var autoUpdate: Boolean = false
|
||||
}
|
||||
|
||||
class ProxiesXml {
|
||||
|
@ -85,6 +88,11 @@ class KobaltSettings @Inject constructor(val xmlFile: KobaltSettingsXml) {
|
|||
*/
|
||||
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
|
||||
* version is the same as the internal version.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.beust.kobalt.app
|
||||
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.internal.KobaltSettings
|
||||
import com.beust.kobalt.internal.build.VersionCheckTimestampFile
|
||||
import com.beust.kobalt.misc.*
|
||||
import com.beust.kobalt.wrapper.Main
|
||||
|
@ -14,7 +15,8 @@ import javax.inject.Inject
|
|||
/**
|
||||
* 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() {
|
||||
val newVersion = github.latestKobaltVersion
|
||||
wrapperProperties.create(newVersion.get())
|
||||
|
@ -43,7 +45,10 @@ class UpdateKobalt @Inject constructor(val github: GithubApi2, val wrapperProper
|
|||
val current = StringVersion(Kobalt.version)
|
||||
val distFile = File(KFiles.distributionsDir)
|
||||
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 " +
|
||||
"./kobaltw --update")
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue