mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
--update
This commit is contained in:
parent
55efaef45e
commit
34c630883c
3 changed files with 28 additions and 4 deletions
|
@ -26,5 +26,7 @@ class Args {
|
|||
@Parameter(names = arrayOf("--tasks"), description = "Display the tasks available for this build")
|
||||
var tasks: Boolean = false
|
||||
|
||||
@Parameter(names = arrayOf("--update"), description = "Update to the latest version of Kobalt")
|
||||
var update: Boolean = false
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ private class Main @Inject constructor(
|
|||
val localRepo: LocalRepo,
|
||||
val depFactory: DepFactory,
|
||||
val checkVersions: CheckVersions,
|
||||
val github: GithubApi)
|
||||
val github: GithubApi,
|
||||
val updateKobalt: UpdateKobalt)
|
||||
: KobaltLogger {
|
||||
|
||||
data class RunInfo(val jc: JCommander, val args: Args)
|
||||
|
@ -63,9 +64,12 @@ private class Main @Inject constructor(
|
|||
val remote = Versions.toLongVersion(github.latestKobaltRelease)
|
||||
val current = Versions.toLongVersion(Kobalt.version)
|
||||
if (remote > current) {
|
||||
log(1, "*****")
|
||||
log(1, "***** New Kobalt version available: ${github.latestKobaltRelease}")
|
||||
log(1, "*****")
|
||||
"***** ".let {
|
||||
log(1, it)
|
||||
log(1, "$it New Kobalt version available: ${github.latestKobaltRelease}")
|
||||
log(1, "$it To update, run ./kobaltw --update")
|
||||
log(1, it )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,6 +156,8 @@ private class Main @Inject constructor(
|
|||
println(sb.toString())
|
||||
} else if (args.checkVersions) {
|
||||
checkVersions.run(output.projects)
|
||||
} else if (args.update) {
|
||||
updateKobalt.updateKobalt()
|
||||
} else {
|
||||
//
|
||||
// Launch the build
|
||||
|
|
16
src/main/kotlin/com/beust/kobalt/misc/UpdateKobalt.kt
Normal file
16
src/main/kotlin/com/beust/kobalt/misc/UpdateKobalt.kt
Normal file
|
@ -0,0 +1,16 @@
|
|||
package com.beust.kobalt.misc
|
||||
|
||||
import com.beust.kobalt.maven.Http
|
||||
import com.google.inject.Inject
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Update Kobalt to the latest version.
|
||||
*/
|
||||
public class UpdateKobalt @Inject constructor(val http: Http, val github: GithubApi) {
|
||||
fun updateKobalt() {
|
||||
val newVersion = github.latestKobaltRelease
|
||||
KFiles.saveFile(File("kobalt/wrapper/kobalt-wrapper.properties"), "kobalt.version=$newVersion")
|
||||
com.beust.kobalt.wrapper.main(arrayOf())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue