From d4ea37bd81cf4305bc36fbbec98b4f4dc95780f4 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 14 Oct 2015 23:10:18 -0700 Subject: [PATCH 01/19] Warnings. --- .../com/beust/kobalt/internal/DynamicGraph.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt b/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt index 7ef6d37d..eaceb07d 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt @@ -4,7 +4,6 @@ import com.beust.kobalt.misc.NamedThreadFactory import com.beust.kobalt.misc.ToString import com.beust.kobalt.misc.log import com.google.common.collect.ArrayListMultimap -import java.util.* import java.util.concurrent.* open class TaskResult2(success: Boolean, val value: T) : TaskResult(success) { @@ -46,7 +45,7 @@ public class DynamicGraphExecutor(val graph: DynamicGraph, synchronized(graph) { val freeNodes = graph.freeNodes freeNodes.forEach { graph.setStatus(it, DynamicGraph.Status.RUNNING)} - log(3, "submitting free nodes ${freeNodes}") + log(3, "submitting free nodes $freeNodes") val callables : List> = factory.createWorkers(freeNodes) callables.forEach { completion.submit(it) } var n = callables.size() @@ -56,7 +55,7 @@ public class DynamicGraphExecutor(val graph: DynamicGraph, try { val future = completion.take() val taskResult = future.get(2, TimeUnit.SECONDS) - log(3, "Received task result ${taskResult}") + log(3, "Received task result $taskResult") n-- graph.setStatus(taskResult.value, if (taskResult.success) { @@ -78,8 +77,6 @@ public class DynamicGraphExecutor(val graph: DynamicGraph, * Representation of the graph of methods. */ public class DynamicGraph { - private val DEBUG = false - private val nodesReady = linkedSetOf() private val nodesRunning = linkedSetOf() private val nodesFinished = linkedSetOf() @@ -92,7 +89,7 @@ public class DynamicGraph { * Define a comparator for the nodes of this graph, which will be used * to order the free nodes when they are asked. */ - public val comparator : Comparator? = null +// public val comparator : Comparator? = null enum class Status { READY, RUNNING, FINISHED, ERROR, SKIPPED @@ -146,7 +143,7 @@ public class DynamicGraph { // } // } - log(3, "freeNodes: ${result}") + log(3, "freeNodes: $result") return result } @@ -176,7 +173,7 @@ public class DynamicGraph { private fun setSkipStatus(node: T, status: Status) { dependingOn.get(node).forEach { if (! nodesSkipped.contains(it)) { - log(3, "Node skipped: ${it}") + log(3, "Node skipped: $it") nodesSkipped.add(it) nodesReady.remove(it) setSkipStatus(it, status) @@ -194,7 +191,7 @@ public class DynamicGraph { Status.RUNNING -> nodesRunning.add(node) Status.FINISHED -> nodesFinished.add(node) Status.ERROR -> { - log(3, "Node in error: ${node}") + log(3, "Node in error: $node") nodesReady.remove(node) nodesInError.add(node) setSkipStatus(node, status) From 62f072d6de65fa5955af98986874eba85d4bca59 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 14 Oct 2015 23:35:26 -0700 Subject: [PATCH 02/19] Better uploading message. --- src/main/kotlin/com/beust/kobalt/Main.kt | 16 ++++-- .../com/beust/kobalt/internal/DynamicGraph.kt | 8 ++- .../com/beust/kobalt/internal/TaskManager.kt | 9 +++- .../kotlin/com/beust/kobalt/maven/Http.kt | 1 + .../com/beust/kobalt/misc/KobaltLogger.kt | 49 +++++++++-------- .../beust/kobalt/plugin/publish/JCenterApi.kt | 53 ++++++++++--------- .../beust/kobalt/internal/DynamicGraphTest.kt | 2 +- 7 files changed, 80 insertions(+), 58 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 0d79d3c9..8b5ab364 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -44,13 +44,13 @@ private class Main @Inject constructor( data class RunInfo(val jc: JCommander, val args: Args) - public fun run(jc: JCommander, args: Args) { - + public fun run(jc: JCommander, args: Args) : Int { + var result = 0 val latestVersionFuture = github.latestKobaltVersion benchmark("Build", { println(Banner.get() + Kobalt.version + "\n") // runTest() - runWithArgs(jc, args) + result = runWithArgs(jc, args) executors.shutdown() debug("All done") }) @@ -67,6 +67,7 @@ private class Main @Inject constructor( log(1, it ) } } + return result } public class Worker(val runNodes: ArrayList, val n: T) : IWorker { @@ -94,7 +95,8 @@ private class Main @Inject constructor( private val SCRIPT_JAR = "buildScript.jar" - private fun runWithArgs(jc: JCommander, args: Args) { + private fun runWithArgs(jc: JCommander, args: Args) : Int { + var result = 0 val p = if (args.buildFile != null) File(args.buildFile) else findBuildFile() args.buildFile = p.absolutePath val buildFile = BuildFile(Paths.get(p.absolutePath), p.name) @@ -154,10 +156,14 @@ private class Main @Inject constructor( // // Launch the build // - taskManager.runTargets(args.targets, allProjects) + val thisResult = taskManager.runTargets(args.targets, allProjects) + if (result == 0) { + result = thisResult + } } } } + return result } private fun findBuildFile(): File { diff --git a/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt b/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt index eaceb07d..b1940076 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt @@ -39,7 +39,11 @@ public class DynamicGraphExecutor(val graph: DynamicGraph, val executor = Executors.newFixedThreadPool(5, NamedThreadFactory("DynamicGraphExecutor")) val completion = ExecutorCompletionService>(executor) - public fun run() { + /** + * @return 0 if all went well, > 0 otherwise + */ + public fun run() : Int { + var lastResult : TaskResult? = null while (graph.freeNodes.size() > 0) { log(3, "Current count: ${graph.nodeCount}") synchronized(graph) { @@ -55,6 +59,7 @@ public class DynamicGraphExecutor(val graph: DynamicGraph, try { val future = completion.take() val taskResult = future.get(2, TimeUnit.SECONDS) + lastResult = taskResult log(3, "Received task result $taskResult") n-- graph.setStatus(taskResult.value, @@ -70,6 +75,7 @@ public class DynamicGraphExecutor(val graph: DynamicGraph, } } executor.shutdown() + return if (lastResult?.success!!) 0 else 1 } } diff --git a/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index e2d3212d..cd9f3782 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -43,7 +43,8 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg fun matches(projectName: String) = project == null || project == projectName } - public fun runTargets(targets: List, projects: List) { + public fun runTargets(targets: List, projects: List) : Int { + var result = 0 val tasksAlreadyRun = hashSetOf() projects.forEach { project -> val projectName = project.name!! @@ -141,10 +142,14 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg } val executor = DynamicGraphExecutor(graph, factory) - executor.run() + val thisResult = executor.run() + if (result == 0) { + result = thisResult + } } } } + return result } /** diff --git a/src/main/kotlin/com/beust/kobalt/maven/Http.kt b/src/main/kotlin/com/beust/kobalt/maven/Http.kt index 5ea69649..9f1ea0bc 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/Http.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/Http.kt @@ -55,6 +55,7 @@ public class Http { .put(RequestBody.create(MEDIA_TYPE_BINARY, file)) .build() + log(2, "Uploading $file to $url") val response = OkHttpClient().newCall(request).execute() if (! response.isSuccessful) { error(response) diff --git a/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt b/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt index 3a6f9a08..bb57bc0c 100644 --- a/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt +++ b/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt @@ -15,9 +15,9 @@ interface KobaltLogger { Logger(false) } - fun log(level: Int, s: String) { + fun log(level: Int, s: String, newLine: Boolean = true) { if (level <= LOG_LEVEL) { - logger.log("Logger", s) + logger.log("Logger", s, newLine) } } @@ -30,28 +30,28 @@ interface KobaltLogger { } } - final fun log(level: Int = 1, message: String) { - if (level <= LOG_LEVEL) { - logger.log("Logger", message) - } - } - - final fun debug(message: String) { - logger.debug(message) - } - - final fun error(message: String, e: Throwable? = null) { - logger.error("Logger", "***** $message", e) - } - - final fun warn(message: String, e: Throwable? = null) { - logger.warn("Logger", message, e) - } +// final fun log(level: Int = 1, message: String) { +// if (level <= LOG_LEVEL) { +// logger.log("Logger", message) +// } +// } +// +// final fun debug(message: String) { +// logger.debug(message) +// } +// +// final fun error(message: String, e: Throwable? = null) { +// logger.error("Logger", "***** $message", e) +// } +// +// final fun warn(message: String, e: Throwable? = null) { +// logger.warn("Logger", message, e) +// } } -fun Any.log(level: Int, text: String) { +fun Any.log(level: Int, text: String, newLine : Boolean = true) { if (level <= KobaltLogger.LOG_LEVEL) { - KobaltLogger.logger.log(javaClass.simpleName, text) + KobaltLogger.logger.log(javaClass.simpleName, text, newLine) } } @@ -88,6 +88,9 @@ class Logger(val dev: Boolean) { final fun warn(tag: String, message: String, e: Throwable? = null) = println(getPattern("W", "***** WARNING ", tag, message)) - final fun log(tag: String, message: String) = - println(getPattern("L", "", tag, message)) + final fun log(tag: String, message: String, newLine: Boolean) = + with(getPattern("L", "", tag, message)) { + if (newLine) println(this) + else print("\r" + this) + } } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt index 43e2cc9b..9ba7ce26 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt @@ -14,6 +14,7 @@ import org.jetbrains.annotations.Nullable import java.io.ByteArrayInputStream import java.io.File import java.nio.charset.Charset +import java.util.concurrent.Callable import javax.inject.Inject data class JCenterPackage(val jo: JsonObject) { @@ -44,7 +45,7 @@ open public class UnauthenticatedJCenterApi @Inject constructor(open val http: H public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val username: String?, @Nullable @Assisted("password") val password: String?, - override val http: Http, val gpg: Gpg) : UnauthenticatedJCenterApi(http) { + override val http: Http, val gpg: Gpg, val executors: KobaltExecutors) : UnauthenticatedJCenterApi(http) { interface IFactory { fun create(@Nullable @Assisted("username") username: String?, @@ -100,8 +101,6 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val private fun upload(files: List, configuration : JCenterConfiguration?, fileToPath: (File) -> String, generateMd5: Boolean = false, generateAsc: Boolean) : TaskResult { - val successes = arrayListOf() - val failures = hashMapOf() val filesToUpload = arrayListOf() if (generateAsc) { @@ -130,34 +129,36 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val // // TODO: These files should be uploaded from a thread pool instead of serially // - log(1, "Found ${filesToUpload.size()} artifacts to upload") - filesToUpload.forEach { - var path = fileToPath(it) - if (options.size() > 0) { - path += "?" + options.join("&") - } + val fileCount = filesToUpload.size() + log(1, "Found $fileCount artifacts to upload") + val callables = filesToUpload.map { FileUploadCallable(username, password, fileToPath(it), it) } + var i = 1 + val results = executors.completionService("FileUpload", 5, 60000000, callables, { tr: TaskResult -> + val last = i >= fileCount + val end = if (last) "\n" else "" + log(1, " Uploading " + (i++) + " / $fileCount$end", false) + }) + val errorMessages = results.filter { ! it.success }.map { it.errorMessage!! } + if (errorMessages.isEmpty()) { + return TaskResult() + } else { + error("Errors while uploading:\n" + errorMessages.map { " $it" }.join("\n")) + return com.beust.kobalt.internal.TaskResult(false, errorMessages.join("\n")) + } + } - log(1, " Uploading $it to $path") - http.uploadFile(username, password, path, it, - { r: Response -> successes.add(it) }, + inner class FileUploadCallable(val username: String?, val password: String?, val url: String, val file: File) + : Callable { + override fun call(): TaskResult? { + var result: TaskResult? = null + http.uploadFile(username, password, url, file, + { result = TaskResult() }, { r: Response -> val jo = parseResponse(r.body().string()) - failures.put(it, jo.string("message") ?: "No message found") + result = TaskResult(false, jo.string("message") ?: "No message found") }) + return result } - val result: TaskResult - if (successes.size() == filesToUpload.size()) { - log(1, "All artifacts successfully uploaded") - result = TaskResult(true) - } else { - result = TaskResult(false, failures.values().join(" ")) - error("Failed to upload ${failures.size()} files:") - failures.forEach{ entry -> - error(" - ${entry.key} : ${entry.value}") - } - } - - return result } } diff --git a/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt b/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt index 19084fec..81965fe6 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt @@ -34,7 +34,7 @@ public class DynamicGraphTest { override val priority = 0 override fun call() : TaskResult2 { - log(2, "Running node $n") + KobaltLogger.log(2, "Running node $n") runNodes.add(n) return TaskResult2(errorFunction(n), n) } From 1eb9e77a46b8aab76245ed17688b4c34f55f04e7 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 14 Oct 2015 23:35:31 -0700 Subject: [PATCH 03/19] Clean up. --- .../kotlin/com/beust/kobalt/misc/KobaltExecutors.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/misc/KobaltExecutors.kt b/src/main/kotlin/com/beust/kobalt/misc/KobaltExecutors.kt index c767bd1a..73180f14 100644 --- a/src/main/kotlin/com/beust/kobalt/misc/KobaltExecutors.kt +++ b/src/main/kotlin/com/beust/kobalt/misc/KobaltExecutors.kt @@ -11,7 +11,7 @@ class NamedThreadFactory(val n: String) : ThreadFactory { override public fun newThread(r: Runnable) : Thread { val result = Thread(r) - result.setName(name + "-" + result.getId()) + result.name = name + "-" + result.id return result } } @@ -25,7 +25,7 @@ class KobaltExecutor(name: String, threadCount: Int) var ex : Throwable? = null if (t == null && r is Future<*>) { try { - if (r.isDone()) r.get(); + if (r.isDone) r.get(); } catch (ce: CancellationException) { ex = ce; } catch (ee: ExecutionException) { @@ -52,8 +52,8 @@ public class KobaltExecutors { miscExecutor.shutdown() } - fun completionService(name: String, threadCount: Int, - maxMs: Long, tasks: List>) : List { + fun completionService(name: String, threadCount: Int, maxMs: Long, tasks: List>, + progress: (T) -> Unit = {}) : List { val result = arrayListOf() val executor = newExecutor(name, threadCount) val cs = ExecutorCompletionService(executor) @@ -64,14 +64,15 @@ public class KobaltExecutors { while (i < tasks.size() && remainingMs >= 0) { var start = System.currentTimeMillis() val r = cs.take().get(remainingMs, TimeUnit.MILLISECONDS) + progress(r) result.add(r) remainingMs -= (System.currentTimeMillis() - start) - log(2, "Received ${r}, remaining: ${remainingMs} ms") + log(2, "Received $r, remaining: $remainingMs ms") i++ } if (remainingMs < 0) { - warn("Didn't receive all the results in time: ${i} / ${tasks.size()}") + warn("Didn't receive all the results in time: $i / ${tasks.size()}") } else { log(2, "Received all results in ${maxMs - remainingMs} ms") } From 6db6e8b9cc4fb457dc9a373fa2c6779466b25ccf Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 14 Oct 2015 23:36:56 -0700 Subject: [PATCH 04/19] 0.184. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 8a33e3a1..265402c1 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.183 \ No newline at end of file +kobalt.version=0.184 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 8a33e3a1..265402c1 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.183 \ No newline at end of file +kobalt.version=0.184 \ No newline at end of file From 70b737f9df67d9dec0f3dd374d39ad737b463c57 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 01:46:54 -0700 Subject: [PATCH 05/19] Add a mainNoExit() --- src/main/kotlin/com/beust/kobalt/Main.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 8b5ab364..52e6b1d8 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -24,9 +24,16 @@ private fun parseArgs(argv: Array): Main.RunInfo { } public fun main(argv: Array) { + val result = mainNoExit(argv) + if (result != 0) { + System.exit(result) + } +} + +public fun mainNoExit(argv: Array) : Int { val (jc, args) = parseArgs(argv) Kobalt.INJECTOR = Guice.createInjector(MainModule(args)) - Kobalt.INJECTOR.getInstance(Main::class.java).run(jc, args) + return Kobalt.INJECTOR.getInstance(Main::class.java).run(jc, args) } private class Main @Inject constructor( From dffb75483d2ce90144e2dc18d7329218a5457b6e Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 01:47:04 -0700 Subject: [PATCH 06/19] Invoke kotlinc's noExit entry point. --- .../kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index d651c774..067adbfe 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -6,6 +6,7 @@ import com.beust.kobalt.internal.TaskResult import com.beust.kobalt.maven.* import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.log +import org.jetbrains.kotlin.cli.common.CLICompiler import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import java.io.File import javax.inject.Inject @@ -52,7 +53,7 @@ class KotlinCompiler @Inject constructor(override val localRepo : LocalRepo, validateClasspath(classpathList) log(2, "Compiling ${source.size()} files with classpath:\n " + classpathList.join("\n ")) - K2JVMCompiler.main(arrayOf( + CLICompiler.doMainNoExit(K2JVMCompiler(), arrayOf( "-d", output, "-classpath", classpathList.join(File.pathSeparator), *source.toTypedArray(), *args.toTypedArray())) From 98f85bf674f41143d2683f7fb1a4a6e2c214276b Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 01:57:29 -0700 Subject: [PATCH 07/19] Better uploading. --- .../beust/kobalt/plugin/publish/JCenterApi.kt | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt index 9ba7ce26..0ae1c2f9 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt @@ -126,39 +126,39 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val val options = arrayListOf() if (configuration?.publish == true) options.add("publish=1") + val optionPath = StringBuffer() + if (options.size() > 0) { + optionPath.append("?" + options.join("&")) + } + // - // TODO: These files should be uploaded from a thread pool instead of serially + // Uploads can'be done in parallel or JCenter rejects them // val fileCount = filesToUpload.size() - log(1, "Found $fileCount artifacts to upload") - val callables = filesToUpload.map { FileUploadCallable(username, password, fileToPath(it), it) } - var i = 1 - val results = executors.completionService("FileUpload", 5, 60000000, callables, { tr: TaskResult -> - val last = i >= fileCount - val end = if (last) "\n" else "" - log(1, " Uploading " + (i++) + " / $fileCount$end", false) - }) - val errorMessages = results.filter { ! it.success }.map { it.errorMessage!! } - if (errorMessages.isEmpty()) { - return TaskResult() + if (fileCount > 0) { + log(1, "Found $fileCount artifacts to upload: " + filesToUpload.get(0) + + if (fileCount > 1) "..." else "") + var i = 1 + val errorMessages = arrayListOf() + filesToUpload.forEach { file -> + http.uploadFile(username, password, fileToPath(file) + optionPath, file, + { }, + { r: Response -> + val jo = parseResponse(r.body().string()) + errorMessages.add(jo.string("message") ?: "No message found") + }) + val end = if (i >= fileCount) "\n" else "" + log(1, " Uploading " + (i++) + " / $fileCount$end", false) + } + if (errorMessages.isEmpty()) { + return TaskResult() + } else { + error("Errors while uploading:\n" + errorMessages.map { " $it" }.join("\n")) + return TaskResult(false, errorMessages.join("\n")) + } } else { - error("Errors while uploading:\n" + errorMessages.map { " $it" }.join("\n")) - return com.beust.kobalt.internal.TaskResult(false, errorMessages.join("\n")) + warn("Found no artifacts to upload") + return TaskResult() } } - - inner class FileUploadCallable(val username: String?, val password: String?, val url: String, val file: File) - : Callable { - override fun call(): TaskResult? { - var result: TaskResult? = null - http.uploadFile(username, password, url, file, - { result = TaskResult() }, - { r: Response -> - val jo = parseResponse(r.body().string()) - result = TaskResult(false, jo.string("message") ?: "No message found") - }) - return result - } - - } } From 06535e392100e51a97797bc0eebf5dac00b1ff2f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 01:57:39 -0700 Subject: [PATCH 08/19] 0.185. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 265402c1..9ae15953 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.184 \ No newline at end of file +kobalt.version=0.185 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 265402c1..9ae15953 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.184 \ No newline at end of file +kobalt.version=0.185 \ No newline at end of file From 042a3153e5a39163ed4c94b78d2d1aeea069875f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 02:01:36 -0700 Subject: [PATCH 09/19] NPE with no args. --- src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt b/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt index b1940076..23d099e1 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt @@ -43,7 +43,7 @@ public class DynamicGraphExecutor(val graph: DynamicGraph, * @return 0 if all went well, > 0 otherwise */ public fun run() : Int { - var lastResult : TaskResult? = null + var lastResult = TaskResult() while (graph.freeNodes.size() > 0) { log(3, "Current count: ${graph.nodeCount}") synchronized(graph) { @@ -75,7 +75,7 @@ public class DynamicGraphExecutor(val graph: DynamicGraph, } } executor.shutdown() - return if (lastResult?.success!!) 0 else 1 + return if (lastResult.success) 0 else 1 } } From 71cd3185d1a8fd698efe77a81a6d726f318efe94 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 02:04:52 -0700 Subject: [PATCH 10/19] 0.186. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 9ae15953..df58a42d 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.185 \ No newline at end of file +kobalt.version=0.186 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 9ae15953..df58a42d 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.185 \ No newline at end of file +kobalt.version=0.186 \ No newline at end of file From 5545d8e41b561b8c6e0d5f995506321afbc5413e Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 02:06:27 -0700 Subject: [PATCH 11/19] Clean up. --- .../com/beust/kobalt/wrapper/Wrapper.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/wrapper/Wrapper.kt b/src/main/kotlin/com/beust/kobalt/wrapper/Wrapper.kt index 45c0ffdb..9162acca 100644 --- a/src/main/kotlin/com/beust/kobalt/wrapper/Wrapper.kt +++ b/src/main/kotlin/com/beust/kobalt/wrapper/Wrapper.kt @@ -55,7 +55,7 @@ public class Wrapper { if (url != null) { readProperties(result, url.openConnection().inputStream) } else { - throw IllegalArgumentException("Couldn't find ${KOBALT_PROPERTIES}") + throw IllegalArgumentException("Couldn't find $KOBALT_PROPERTIES") } return result @@ -64,7 +64,7 @@ public class Wrapper { private fun initWrapperFile(version: String) { val config = File(WRAPPER_DIR, KOBALT_WRAPPER_PROPERTIES) if (! config.exists()) { - KFiles.saveFile(config, "${PROPERTY_VERSION}=${version}") + KFiles.saveFile(config, "$PROPERTY_VERSION=$version") } properties.load(FileReader(config)) } @@ -84,16 +84,16 @@ public class Wrapper { val version = properties.getProperty(PROPERTY_VERSION) initWrapperFile(version) - log(2, "Wrapper version: ${wrapperVersion}") + log(2, "Wrapper version: $wrapperVersion") - val fileName = "${FILE_NAME}-${wrapperVersion}.zip" + val fileName = "$FILE_NAME-$wrapperVersion.zip" File(KFiles.distributionsDir).mkdirs() val localZipFile = Paths.get(KFiles.distributionsDir, fileName) val zipOutputDir = KFiles.distributionsDir + "/" + wrapperVersion - val kobaltJarFile = Paths.get(zipOutputDir, "kobalt/wrapper/${FILE_NAME}-${wrapperVersion}.jar") + 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}" + log(1, "Downloading $fileName") + val fullUrl = "$URL/$fileName" val body = Http().get(fullUrl) if (body.code == 200) { if (!Files.exists(localZipFile)) { @@ -105,9 +105,9 @@ public class Wrapper { // the BufferedSource returned in the ResponseBody Files.copy(ins, target) } - log(2, "${localZipFile} downloaded, extracting it") + log(2, "$localZipFile downloaded, extracting it") } else { - log(2, "${localZipFile} already exists, extracting it") + log(2, "$localZipFile already exists, extracting it") } // @@ -124,16 +124,16 @@ public class Wrapper { entryFile.mkdirs() } else { val dest = Paths.get(zipOutputDir, entryFile.path) - log(2, " Writing ${entry.name} to ${dest}") + log(2, " Writing ${entry.name} to $dest") Files.createDirectories(dest.parent) Files.copy(zipFile.getInputStream(entry), dest, java.nio.file.StandardCopyOption.REPLACE_EXISTING) } } - log(2, "${localZipFile} extracted") + log(2, "$localZipFile extracted") } else { - error("Couldn't download ${URL}") + error("Couldn't download $URL") } } @@ -141,7 +141,7 @@ public class Wrapper { // Copy the wrapper files in the current kobalt/wrapper directory // log(2, "Copying the wrapper files...") - arrayListOf(KOBALTW, "kobalt/wrapper/${FILE_NAME}-wrapper.jar").forEach { + arrayListOf(KOBALTW, "kobalt/wrapper/$FILE_NAME-wrapper.jar").forEach { val from = Paths.get(zipOutputDir, it) val to = Paths.get(File(".").absolutePath, it) KFiles.copy(from, to, java.nio.file.StandardCopyOption.REPLACE_EXISTING) @@ -169,7 +169,7 @@ public class Wrapper { args.addAll(argv) val pb = ProcessBuilder(args) pb.inheritIO() - log(1, "Launching\n ${args.join(" ")}") + log(2, "Launching\n ${args.join(" ")}") val process = pb.start() process.waitFor() } From 6c1afbfd99c40fe7aee25fff07cc8918b4aff426 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 02:58:08 -0700 Subject: [PATCH 12/19] Unused log functions. --- .../com/beust/kobalt/misc/KobaltLogger.kt | 58 +++++-------------- .../beust/kobalt/internal/DynamicGraphTest.kt | 3 +- 2 files changed, 15 insertions(+), 46 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt b/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt index bb57bc0c..68cf4a77 100644 --- a/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt +++ b/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt @@ -4,51 +4,6 @@ import com.beust.kobalt.api.Kobalt import java.text.SimpleDateFormat import java.util.* -interface KobaltLogger { - companion object { - public var LOG_LEVEL : Int = 1 - - val logger : Logger get() = - if (Kobalt.context != null) { - Logger(Kobalt.context!!.args.dev) - } else { - Logger(false) - } - - fun log(level: Int, s: String, newLine: Boolean = true) { - if (level <= LOG_LEVEL) { - logger.log("Logger", s, newLine) - } - } - - fun warn(s: String, e: Throwable? = null) { - logger.warn("Logger", s, e) - } - - fun debug(s: String) { - logger.debug(s) - } - } - -// final fun log(level: Int = 1, message: String) { -// if (level <= LOG_LEVEL) { -// logger.log("Logger", message) -// } -// } -// -// final fun debug(message: String) { -// logger.debug(message) -// } -// -// final fun error(message: String, e: Throwable? = null) { -// logger.error("Logger", "***** $message", e) -// } -// -// final fun warn(message: String, e: Throwable? = null) { -// logger.warn("Logger", message, e) -// } -} - fun Any.log(level: Int, text: String, newLine : Boolean = true) { if (level <= KobaltLogger.LOG_LEVEL) { KobaltLogger.logger.log(javaClass.simpleName, text, newLine) @@ -67,6 +22,19 @@ fun Any.error(text: String, e: Throwable? = null) { KobaltLogger.logger.error(javaClass.simpleName, text, e) } +interface KobaltLogger { + companion object { + public var LOG_LEVEL: Int = 1 + + val logger: Logger get() = + if (Kobalt.context != null) { + Logger(Kobalt.context!!.args.dev) + } else { + Logger(false) + } + } +} + class Logger(val dev: Boolean) { val FORMAT = SimpleDateFormat("HH:mm:ss.SSS") diff --git a/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt b/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt index 81965fe6..a1695679 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt @@ -3,6 +3,7 @@ package com.beust.kobalt.internal import com.beust.kobalt.maven.KobaltException import com.beust.kobalt.misc.KobaltLogger import com.beust.kobalt.misc.Topological +import com.beust.kobalt.misc.log import javafx.concurrent.Worker import org.testng.Assert import org.testng.annotations.Test @@ -34,7 +35,7 @@ public class DynamicGraphTest { override val priority = 0 override fun call() : TaskResult2 { - KobaltLogger.log(2, "Running node $n") + log(2, "Running node $n") runNodes.add(n) return TaskResult2(errorFunction(n), n) } From 814777e55356163111dcc52b310a4e010303efd0 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 03:27:18 -0700 Subject: [PATCH 13/19] Optimize graph run. --- .../com/beust/kobalt/internal/DynamicGraph.kt | 7 ++- .../com/beust/kobalt/internal/TaskManager.kt | 57 ++++++++----------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt b/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt index 23d099e1..b89cc029 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt @@ -4,6 +4,7 @@ import com.beust.kobalt.misc.NamedThreadFactory import com.beust.kobalt.misc.ToString import com.beust.kobalt.misc.log import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.HashMultimap import java.util.concurrent.* open class TaskResult2(success: Boolean, val value: T) : TaskResult(success) { @@ -88,8 +89,8 @@ public class DynamicGraph { private val nodesFinished = linkedSetOf() private val nodesInError = linkedSetOf() private val nodesSkipped = linkedSetOf() - private val dependedUpon = ArrayListMultimap.create() - private val dependingOn = ArrayListMultimap.create() + private val dependedUpon = HashMultimap.create() + private val dependingOn = HashMultimap.create() /** * Define a comparator for the nodes of this graph, which will be used @@ -156,7 +157,7 @@ public class DynamicGraph { /** * @return a list of all the nodes that have a status other than FINISHED. */ - private fun getUnfinishedNodes(nodes: List) : Collection { + private fun getUnfinishedNodes(nodes: Set) : Collection { val result = hashSetOf() nodes.forEach { node -> if (nodesReady.contains(node) || nodesRunning.contains(node)) { diff --git a/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index cd9f3782..d91cf9e5 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -45,7 +45,6 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg public fun runTargets(targets: List, projects: List) : Int { var result = 0 - val tasksAlreadyRun = hashSetOf() projects.forEach { project -> val projectName = project.name!! val tasksByNames = hashMapOf() @@ -59,8 +58,8 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg log(1, " Building project ${project.name}") log(1, "") + val graph = DynamicGraph() targets.forEach { target -> - val graph = DynamicGraph() val ti = TaskInfo(target) if (ti.matches(projectName)) { @@ -84,10 +83,7 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg if (currentFreeTask.size() == 1) { currentFreeTask.get(0).let { val thisTaskInfo = TaskInfo(projectName, it.name) - if (! tasksAlreadyRun.contains(thisTaskInfo.id)) { - graph.addNode(it) - tasksAlreadyRun.add(thisTaskInfo.id) - } + graph.addNode(it) } } @@ -100,11 +96,7 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg rb.forEach { val to = tasksByNames.get(it) if (to != null) { - val taskInfo = TaskInfo(projectName, to.name) - if (! tasksAlreadyRun.contains(taskInfo.id)) { - graph.addEdge(pluginTask, to) - tasksAlreadyRun.add(taskInfo.id) - } + graph.addEdge(pluginTask, to) } else { throw KobaltException("Should have found $it") } @@ -125,29 +117,30 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg } } } - - log(2, "About to run graph:\n ${graph.dump()} ") - - // - // Now that we have a full graph, run it - // - val factory = object : IThreadWorkerFactory { - override public fun createWorkers(nodes: List): List> { - val result = arrayListOf>() - nodes.forEach { - result.add(TaskWorker(arrayListOf(it), args.dryRun)) - } - return result - } - } - - val executor = DynamicGraphExecutor(graph, factory) - val thisResult = executor.run() - if (result == 0) { - result = thisResult - } } } + + // + // Now that we have a full graph, run it + // + log(2, "About to run graph:\n ${graph.dump()} ") + + val factory = object : IThreadWorkerFactory { + override public fun createWorkers(nodes: List): List> { + val result = arrayListOf>() + nodes.forEach { + result.add(TaskWorker(arrayListOf(it), args.dryRun)) + } + return result + } + } + + val executor = DynamicGraphExecutor(graph, factory) + val thisResult = executor.run() + if (result == 0) { + result = thisResult + } + } return result } From 806628be4ad5169e8fe048c96362f55fe408a4d0 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 03:27:27 -0700 Subject: [PATCH 14/19] Better display. --- .../kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt index 0ae1c2f9..412606cd 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt @@ -140,15 +140,17 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val + if (fileCount > 1) "..." else "") var i = 1 val errorMessages = arrayListOf() + var dots = "" filesToUpload.forEach { file -> http.uploadFile(username, password, fileToPath(file) + optionPath, file, - { }, + { r: Response -> dots += "."}, { r: Response -> + dots += "X" val jo = parseResponse(r.body().string()) errorMessages.add(jo.string("message") ?: "No message found") }) val end = if (i >= fileCount) "\n" else "" - log(1, " Uploading " + (i++) + " / $fileCount$end", false) + log(1, " Uploading " + (i++) + " / $fileCount$end $dots", false) } if (errorMessages.isEmpty()) { return TaskResult() From 10f8f338456f96f698e3e2c5ad52a090eeb506a4 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 03:27:37 -0700 Subject: [PATCH 15/19] 0.187. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index df58a42d..addf4709 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.186 \ No newline at end of file +kobalt.version=0.187 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index df58a42d..addf4709 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.186 \ No newline at end of file +kobalt.version=0.187 \ No newline at end of file From c1214c999431b5aa9e0d348be15f7c531e534e6f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 03:39:07 -0700 Subject: [PATCH 16/19] Dots. --- .../beust/kobalt/plugin/publish/JCenterApi.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt index 412606cd..985a3eb7 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt @@ -2,6 +2,7 @@ package com.beust.kobalt.plugin.publish import com.beust.klaxon.* import com.beust.kobalt.api.Project +import com.beust.kobalt.dots import com.beust.kobalt.internal.TaskResult import com.beust.kobalt.maven.Gpg import com.beust.kobalt.maven.Http @@ -140,17 +141,24 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val + if (fileCount > 1) "..." else "") var i = 1 val errorMessages = arrayListOf() - var dots = "" + + + fun dots(total: Int, list: List) : String { + val spaces : String = Array(total - list.size(), { " " }).join("") + return "|" + list.map { if (it) "." else "X" }.join("") + spaces + "|" + } + + val results = arrayListOf() filesToUpload.forEach { file -> http.uploadFile(username, password, fileToPath(file) + optionPath, file, - { r: Response -> dots += "."}, + { r: Response -> results.add(true)}, { r: Response -> - dots += "X" + results.add(false) val jo = parseResponse(r.body().string()) errorMessages.add(jo.string("message") ?: "No message found") }) val end = if (i >= fileCount) "\n" else "" - log(1, " Uploading " + (i++) + " / $fileCount$end $dots", false) + log(1, " Uploading " + (i++) + " / $fileCount$end " + dots(fileCount, results), false) } if (errorMessages.isEmpty()) { return TaskResult() From 46f847b90a416123e565431eef9e712940eb8720 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 03:44:04 -0700 Subject: [PATCH 17/19] Logs. --- src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt | 2 +- .../kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt | 4 ++-- .../kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt | 2 +- .../com/beust/kobalt/plugin/packaging/PackagingPlugin.kt | 2 +- .../kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt | 8 +++----- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt b/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt index a67a47b6..736bf249 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt @@ -57,6 +57,6 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) { val pomFile = SimpleDep(project.group!!, project.artifactId!!, project.version!!).toPomFileName() val outputFile = File(outputDir, pomFile) outputFile.writeText(s.toString(), Charset.defaultCharset()) - log(1, "Wrote $outputFile") + log(1, " Wrote $outputFile") } } \ No newline at end of file diff --git a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt index 590c8cf5..40815f67 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt @@ -65,8 +65,8 @@ public class JavaPlugin @Inject constructor( // pb.redirectError(File("/tmp/kobalt-err")) // pb.redirectOutput(File("/tmp/kobalt-out")) val line = args.join(" ") - log(1, "Compiling ${sourceFiles.size()} files with classpath size ${cpList.size()}") - log(2, "Compiling ${project}:\n${line}") + log(1, " Compiling ${sourceFiles.size()} files with classpath size ${cpList.size()}") + log(2, " Compiling $project:\n$line") val process = pb.start() val errorCode = process.waitFor() diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt index 31dfe263..eb633546 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt @@ -83,7 +83,7 @@ public class KotlinPlugin @Inject constructor( outputDirectory: String): TaskResult { File(outputDirectory).mkdirs() - log(1, "Compiling ${sources.size()} files with classpath size ${cpList.size()}") + log(1, " Compiling ${sources.size()} files with classpath size ${cpList.size()}") return kotlinCompilePrivate { classpath(cpList.map { it.jarFile.get().absolutePath }) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt index b9733db4..335e27e4 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt @@ -218,7 +218,7 @@ public class PackagingPlugin @Inject constructor(val dependencyManager : Depende log(2, "Added ${includedFiles.size()} files to ${result}") outStream.flush() outStream.close() - log(1, "Created ${result}") + log(1, " Created ${result}") return result } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt index 985a3eb7..80b7b74e 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt @@ -2,7 +2,6 @@ package com.beust.kobalt.plugin.publish import com.beust.klaxon.* import com.beust.kobalt.api.Project -import com.beust.kobalt.dots import com.beust.kobalt.internal.TaskResult import com.beust.kobalt.maven.Gpg import com.beust.kobalt.maven.Http @@ -15,7 +14,6 @@ import org.jetbrains.annotations.Nullable import java.io.ByteArrayInputStream import java.io.File import java.nio.charset.Charset -import java.util.concurrent.Callable import javax.inject.Inject data class JCenterPackage(val jo: JsonObject) { @@ -137,7 +135,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val // val fileCount = filesToUpload.size() if (fileCount > 0) { - log(1, "Found $fileCount artifacts to upload: " + filesToUpload.get(0) + log(1, " Found $fileCount artifacts to upload: " + filesToUpload.get(0) + if (fileCount > 1) "..." else "") var i = 1 val errorMessages = arrayListOf() @@ -158,12 +156,12 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val errorMessages.add(jo.string("message") ?: "No message found") }) val end = if (i >= fileCount) "\n" else "" - log(1, " Uploading " + (i++) + " / $fileCount$end " + dots(fileCount, results), false) + log(1, " Uploading " + (i++) + " / $fileCount$end " + dots(fileCount, results), false) } if (errorMessages.isEmpty()) { return TaskResult() } else { - error("Errors while uploading:\n" + errorMessages.map { " $it" }.join("\n")) + error("Errors while uploading:\n" + errorMessages.map { " $it" }.join("\n")) return TaskResult(false, errorMessages.join("\n")) } } else { From 51b06a8186b0be8635c55ea10917cde2dfed8faa Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 03:45:42 -0700 Subject: [PATCH 18/19] Formatting. --- src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt index 80b7b74e..d8a48170 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt @@ -156,7 +156,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val errorMessages.add(jo.string("message") ?: "No message found") }) val end = if (i >= fileCount) "\n" else "" - log(1, " Uploading " + (i++) + " / $fileCount$end " + dots(fileCount, results), false) + log(1, " Uploading " + (i++) + " / $fileCount " + dots(fileCount, results) + end, false) } if (errorMessages.isEmpty()) { return TaskResult() From a65d77487b658f2116186b1724f89724a9b5aa73 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 15 Oct 2015 03:45:50 -0700 Subject: [PATCH 19/19] 0.189. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index addf4709..439adc3f 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.187 \ No newline at end of file +kobalt.version=0.189 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index addf4709..439adc3f 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.187 \ No newline at end of file +kobalt.version=0.189 \ No newline at end of file