From 13b87527f67dd4c41e77b123af1f21d0e2e305e6 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 10 Nov 2015 11:05:15 -0800 Subject: [PATCH] Update to github for releases. --- kobalt/src/Build.kt | 29 +++++-- kobalt/wrapper/kobalt-wrapper.jar | Bin 6806 -> 6806 bytes kobalt/wrapper/kobalt-wrapper.properties | 3 +- .../java/com/beust/kobalt/wrapper/Main.java | 26 ++++-- src/main/kotlin/com/beust/kobalt/Main.kt | 5 +- .../kobalt/misc/KobaltWrapperProperties.kt | 45 ++++++++++- .../com/beust/kobalt/misc/UpdateKobalt.kt | 5 +- .../com/beust/kobalt/wrapper/Wrapper.kt | 75 ++++++++++-------- src/main/resources/kobalt.properties | 3 +- 9 files changed, 137 insertions(+), 54 deletions(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 5139b526..06e43965 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -1,7 +1,9 @@ import com.beust.kobalt.api.License +import com.beust.kobalt.api.Project import com.beust.kobalt.api.Scm import com.beust.kobalt.homeDir +import com.beust.kobalt.internal.TaskResult import com.beust.kobalt.internal.test import com.beust.kobalt.plugin.application.application import com.beust.kobalt.plugin.java.javaCompiler @@ -9,8 +11,10 @@ import com.beust.kobalt.plugin.java.javaProject import com.beust.kobalt.plugin.kotlin.kotlinCompiler import com.beust.kobalt.plugin.kotlin.kotlinProject import com.beust.kobalt.plugin.packaging.assemble -import com.beust.kobalt.plugin.publish.jcenter import java.io.File +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption val wrapper = javaProject { name = "kobalt-wrapper" @@ -87,18 +91,22 @@ val kobalt = kotlinProject(wrapper) { } } +// install { +// libDir = "lib-test" +// } + test { - args("-log", "2", "src/test/resources/testng.xml") + args("-log", "1", "src/test/resources/testng.xml") } kotlinCompiler { args("-nowarn") } - jcenter { - publish = true - file("$buildDirectory/libs/$name-$version.zip", "$name/$version/$name-$version.zip") - } +// jcenter { +// publish = true +// file("$buildDirectory/libs/$name-$version.zip", "$name/$version/$name-$version.zip") +// } } fun readVersion() : String { @@ -111,6 +119,15 @@ fun readVersion() : String { return p.getProperty("kobalt.version") } +@com.beust.kobalt.api.annotation.Task(name = "copyVersionForWrapper", runBefore = arrayOf("compile"), description = "") +fun taskCopyVersionForWrapper(project: Project) : TaskResult { + if (project.name == "kobalt-wrapper") { + Files.copy(Paths.get("src/main/resources/kobalt.properties"), + Paths.get("modules/wrapper/kobaltBuild/classes/kobalt.properties"), + StandardCopyOption.REPLACE_EXISTING) + } + return TaskResult() +} //import com.beust.kobalt.plugin.linecount.lineCount //val plugins = plugins( // "com.beust.kobalt:kobalt-line-count:0.15" diff --git a/kobalt/wrapper/kobalt-wrapper.jar b/kobalt/wrapper/kobalt-wrapper.jar index c71f7c074f41e66fddd9bda4d46b03b193c6a5b8..5ae9002f9baad7c81e4e998a0240419f25623ca1 100644 GIT binary patch delta 54 zcmbPcI?a?Pz?+#xgn@&DgF$H3MxKXa+>e) { - Wrapper().installAndLaunchMain(argv) + Kobalt.INJECTOR.getInstance(Wrapper::class.java).installAndLaunchMain(argv) } /** * Download and install a new wrapper if requested. */ -public class Wrapper { +public class Wrapper @Inject constructor(val wrapperProperties: KobaltWrapperProperties){ // kobalt.properties private val KOBALT_PROPERTIES = "kobalt.properties" private val KOBALTW = "kobaltw" - private val WRAPPER_DIR = KFiles.KOBALT_DIR + "/wrapper" - private val KOBALT_WRAPPER_PROPERTIES = "kobalt-wrapper.properties" - private val PROPERTY_VERSION = "kobalt.version" - - val URL = "https://dl.bintray.com/cbeust/generic/" val FILE_NAME = "kobalt" private val properties = Properties() @@ -47,7 +44,10 @@ public class Wrapper { properties.forEach { es -> System.setProperty(es.key.toString(), es.value.toString()) } } - private fun maybeCreateProperties() : Properties { + /** + * Attemps to read kobalt.properties (which should always exist). + */ + private fun maybeCreateKobaltProperties() : Properties { val result = Properties() // kobalt.properties is internal to Kobalt @@ -61,18 +61,29 @@ public class Wrapper { return result } - private fun initWrapperFile(version: String) { - val config = File(WRAPPER_DIR, KOBALT_WRAPPER_PROPERTIES) - if (! config.exists()) { - KFiles.saveFile(config, "$PROPERTY_VERSION=$version") - } - properties.load(FileReader(config)) - } - - private val wrapperVersion : String - get() { - return properties.getProperty(PROPERTY_VERSION) - } +// private fun initWrapperFile(version: String) { +// val config = wrapperProperties.file +// if (! config.exists()) { +// wrapperProperties.create(version) +// } +// properties.load(FileReader(config)) +// } +// +// private val wrapperVersion : String +// get() { +// return properties.getProperty(PROPERTY_VERSION) +// } +// +// private val wrapperDownloadUrl : String +// get() { +// return properties.getProperty(PROPERTY_DOWNLOAD_URL) +// } +// +// fun urlFor(version: String) : String { +// // val URL = "https://dl.bintray.com/cbeust/generic/" +// // return "https://dl.bintray.com/cbeust/generic/$fileName-$version.zip" +// return wrapperDownloadUrl ?: defaultUrlFor(version) +// } /** * Install a new version if requested in .kobalt/wrapper/kobalt-wrapper.properties @@ -80,12 +91,12 @@ public class Wrapper { * @return the path to the Kobalt jar file */ public fun install() : Path { - val properties = maybeCreateProperties() - val version = properties.getProperty(PROPERTY_VERSION) - initWrapperFile(version) - - log(2, "Wrapper version: $wrapperVersion") + val properties = maybeCreateKobaltProperties() + val version = properties.getProperty("kobalt.version") + wrapperProperties.maybeCreate(version) + log(2, "Wrapper version: ${wrapperProperties.version}") + val wrapperVersion = wrapperProperties.version val fileName = "$FILE_NAME-$wrapperVersion.zip" File(KFiles.distributionsDir).mkdirs() val localZipFile = Paths.get(KFiles.distributionsDir, fileName) @@ -93,7 +104,7 @@ public class Wrapper { val kobaltJarFile = Paths.get(zipOutputDir, "kobalt/wrapper/$FILE_NAME-$wrapperVersion.jar") if (!Files.exists(localZipFile) || !Files.exists(kobaltJarFile)) { log(1, "Downloading $fileName") - val fullUrl = "$URL/$fileName" + val fullUrl = wrapperProperties.downloadUrl val body = Http().get(fullUrl) if (body.code == 200) { if (!Files.exists(localZipFile)) { @@ -133,7 +144,7 @@ public class Wrapper { } log(2, "$localZipFile extracted") } else { - error("Couldn't download $URL") + error("Couldn't download $fullUrl") } } diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 120b1444..b27d957c 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1,2 @@ -kobalt.version=0.234 +kobalt.version=0.238 +