mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -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")
|
@Parameter(names = arrayOf("--tasks"), description = "Display the tasks available for this build")
|
||||||
var tasks: Boolean = false
|
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 localRepo: LocalRepo,
|
||||||
val depFactory: DepFactory,
|
val depFactory: DepFactory,
|
||||||
val checkVersions: CheckVersions,
|
val checkVersions: CheckVersions,
|
||||||
val github: GithubApi)
|
val github: GithubApi,
|
||||||
|
val updateKobalt: UpdateKobalt)
|
||||||
: KobaltLogger {
|
: KobaltLogger {
|
||||||
|
|
||||||
data class RunInfo(val jc: JCommander, val args: Args)
|
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 remote = Versions.toLongVersion(github.latestKobaltRelease)
|
||||||
val current = Versions.toLongVersion(Kobalt.version)
|
val current = Versions.toLongVersion(Kobalt.version)
|
||||||
if (remote > current) {
|
if (remote > current) {
|
||||||
log(1, "*****")
|
"***** ".let {
|
||||||
log(1, "***** New Kobalt version available: ${github.latestKobaltRelease}")
|
log(1, it)
|
||||||
log(1, "*****")
|
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())
|
println(sb.toString())
|
||||||
} else if (args.checkVersions) {
|
} else if (args.checkVersions) {
|
||||||
checkVersions.run(output.projects)
|
checkVersions.run(output.projects)
|
||||||
|
} else if (args.update) {
|
||||||
|
updateKobalt.updateKobalt()
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Launch the build
|
// 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