mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Check new version.
This commit is contained in:
parent
c45bf49c7d
commit
1af54ec0eb
4 changed files with 64 additions and 16 deletions
|
@ -34,25 +34,13 @@ private class Main @Inject constructor(
|
||||||
val localRepo: LocalRepo,
|
val localRepo: LocalRepo,
|
||||||
val depFactory: DepFactory,
|
val depFactory: DepFactory,
|
||||||
val checkVersions: CheckVersions,
|
val checkVersions: CheckVersions,
|
||||||
val jcenter: UnauthenticatedJCenterApi)
|
val jcenter: UnauthenticatedJCenterApi,
|
||||||
|
val github: GithubApi)
|
||||||
: KobaltLogger {
|
: KobaltLogger {
|
||||||
|
|
||||||
data class RunInfo(val jc: JCommander, val args: Args)
|
data class RunInfo(val jc: JCommander, val args: Args)
|
||||||
|
|
||||||
public fun run(argv: Array<String>) {
|
public fun run(argv: Array<String>) {
|
||||||
// Check for new version
|
|
||||||
// Commented out until I can find a way to get the latest available download
|
|
||||||
// from bintray. Right now, it always returns all the versions uploaded, not
|
|
||||||
// just the one I mark
|
|
||||||
// val p = jcenter.kobaltPackage
|
|
||||||
// val current = Versions.toLongVersion(Kobalt.version)
|
|
||||||
// val remote = Versions.toLongVersion(p.latestPublishedVersion)
|
|
||||||
// if (remote > current) {
|
|
||||||
// log(1, "*****")
|
|
||||||
// log(1, "***** New Kobalt version available: ${p.latestPublishedVersion}")
|
|
||||||
// log(1, "*****")
|
|
||||||
// }
|
|
||||||
|
|
||||||
benchmark("Build", {
|
benchmark("Build", {
|
||||||
println(Banner.get() + Kobalt.version + "\n")
|
println(Banner.get() + Kobalt.version + "\n")
|
||||||
// runTest()
|
// runTest()
|
||||||
|
@ -61,6 +49,17 @@ private class Main @Inject constructor(
|
||||||
executors.shutdown()
|
executors.shutdown()
|
||||||
debug("All done")
|
debug("All done")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Check for new version
|
||||||
|
// TODO(cbeust): Start the network call at the beginning of the build and
|
||||||
|
// get the future here, at the end of the build
|
||||||
|
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, "*****")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Worker<T>(val runNodes: ArrayList<T>, val n: T) : IWorker<T>, KobaltLogger {
|
public class Worker<T>(val runNodes: ArrayList<T>, val n: T) : IWorker<T>, KobaltLogger {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.beust.kobalt.api
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.maven.MavenDependency
|
import com.beust.kobalt.maven.MavenDependency
|
||||||
import com.beust.kobalt.maven.IClasspathDependency
|
import com.beust.kobalt.maven.IClasspathDependency
|
||||||
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.google.common.base.Preconditions
|
import com.google.common.base.Preconditions
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@ open public class Project(
|
||||||
open var name: String? = null,
|
open var name: String? = null,
|
||||||
open var version: String? = null,
|
open var version: String? = null,
|
||||||
open var directory: String = ".",
|
open var directory: String = ".",
|
||||||
open var buildDirectory: String? = "kobaltBuild",
|
open var buildDirectory: String? = KFiles.KOBALT_BUILD_DIR,
|
||||||
open var group: String? = null,
|
open var group: String? = null,
|
||||||
open var artifactId: String? = null,
|
open var artifactId: String? = null,
|
||||||
open var dependencies: Dependencies? = null,
|
open var dependencies: Dependencies? = null,
|
||||||
|
|
37
src/main/kotlin/com/beust/kobalt/misc/GithubApi.kt
Normal file
37
src/main/kotlin/com/beust/kobalt/misc/GithubApi.kt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package com.beust.kobalt.misc
|
||||||
|
|
||||||
|
import com.beust.klaxon.JsonArray
|
||||||
|
import com.beust.klaxon.JsonObject
|
||||||
|
import com.beust.klaxon.Parser
|
||||||
|
import com.beust.klaxon.string
|
||||||
|
import com.beust.kobalt.maven.Http
|
||||||
|
import com.google.inject.Inject
|
||||||
|
import java.io.IOException
|
||||||
|
import java.net.URL
|
||||||
|
|
||||||
|
public class GithubApi @Inject constructor(val http: Http) : KobaltLogger {
|
||||||
|
companion object {
|
||||||
|
const val HOST = "https://api.github.com/"
|
||||||
|
}
|
||||||
|
|
||||||
|
val latestKobaltRelease: String
|
||||||
|
get() {
|
||||||
|
val url = HOST + "repos/cbeust/kobalt/releases"
|
||||||
|
try {
|
||||||
|
val ins = URL(url).openConnection().inputStream
|
||||||
|
val jo = Parser().parse(ins) as JsonArray<JsonObject>
|
||||||
|
if (jo.size() > 0) {
|
||||||
|
var result = jo.get(0).string("name")
|
||||||
|
if (result == null) {
|
||||||
|
result = jo.get(0).string("tag_name")
|
||||||
|
}
|
||||||
|
if (result != null) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(ex: IOException) {
|
||||||
|
warn("Couldn't load the release URL: ${url}")
|
||||||
|
}
|
||||||
|
return "0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,17 @@ import java.nio.file.StandardCopyOption
|
||||||
|
|
||||||
public class KFiles {
|
public class KFiles {
|
||||||
val kobaltJar : String
|
val kobaltJar : String
|
||||||
get() = joinDir(distributionsDir, Kobalt.version, "kobalt/wrapper/kobalt-" + Kobalt.version + ".jar")
|
get() {
|
||||||
|
val jar = joinDir(distributionsDir, Kobalt.version, "kobalt/wrapper/kobalt-" + Kobalt.version + ".jar")
|
||||||
|
val jarFile = File(jar)
|
||||||
|
if (! jarFile.exists()) {
|
||||||
|
// Will only happen when building kobalt itself: the jar file might not be in the dist/ directory
|
||||||
|
// yet since we're currently building it. Instead, use the classes directly
|
||||||
|
return File(joinDir("build", "classes", "main")).absolutePath
|
||||||
|
} else {
|
||||||
|
return jar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
File(KOBALT_DOT_DIR).mkdirs()
|
File(KOBALT_DOT_DIR).mkdirs()
|
||||||
|
@ -24,6 +34,7 @@ public class KFiles {
|
||||||
companion object {
|
companion object {
|
||||||
private const val KOBALT_DOT_DIR : String = ".kobalt"
|
private const val KOBALT_DOT_DIR : String = ".kobalt"
|
||||||
const val KOBALT_DIR : String = "kobalt"
|
const val KOBALT_DIR : String = "kobalt"
|
||||||
|
const val KOBALT_BUILD_DIR = "kobaltBuild"
|
||||||
|
|
||||||
// Directories under ~/.kobalt
|
// Directories under ~/.kobalt
|
||||||
public val localRepo = homeDir(KOBALT_DOT_DIR, "repository")
|
public val localRepo = homeDir(KOBALT_DOT_DIR, "repository")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue