From 371929f75433385cf4281db18e42d82996985a33 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 6 Dec 2015 11:02:56 -0800 Subject: [PATCH] Fix --tasks. --- src/main/kotlin/com/beust/kobalt/Main.kt | 43 +++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 691029b7..bff3c6b8 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -3,6 +3,7 @@ package com.beust.kobalt import com.beust.jcommander.JCommander import com.beust.kobalt.api.IClasspathDependency import com.beust.kobalt.api.Kobalt +import com.beust.kobalt.api.PluginTask import com.beust.kobalt.api.Project import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.internal.TaskManager @@ -14,6 +15,7 @@ import com.beust.kobalt.maven.DepFactory import com.beust.kobalt.maven.Http import com.beust.kobalt.maven.LocalRepo import com.beust.kobalt.misc.* +import com.google.common.collect.HashMultimap import com.google.inject.Guice import java.io.File import java.nio.file.Paths @@ -174,23 +176,16 @@ private class Main @Inject constructor( // --resolve resolveDependency.run(args.dependency as String) } else if (args.tasks) { - // - // List of tasks - // - val sb = StringBuffer("List of tasks\n") - taskManager.tasks.distinctBy { - it.name - }.forEach { task -> - sb.append("\n " + AsciiArt.horizontalDoubleLine +" ${task.plugin.name} " - + AsciiArt.horizontalDoubleLine + "\n") - sb.append(" ${task.name}\t\t${task.doc}\n") - println(sb.toString()) - } + // --tasks + displayTasks() } else if (args.checkVersions) { + // --checkVersions checkVersions.run(allProjects) } else if (args.download) { + // -- download updateKobalt.downloadKobalt() } else if (args.update) { + // --update updateKobalt.updateKobalt() } else { // @@ -206,6 +201,30 @@ private class Main @Inject constructor( return result } + private fun displayTasks() { + // + // List of tasks, --tasks + // + val tasksByPlugins = HashMultimap.create() + taskManager.tasks.forEach { + tasksByPlugins.put(it.plugin.name, it) + } + val sb = StringBuffer("List of tasks\n") + tasksByPlugins.keySet().forEach { name -> + sb.append("\n " + AsciiArt.horizontalDoubleLine + " $name " + + AsciiArt.horizontalDoubleLine + "\n") + tasksByPlugins[name].distinctBy { + it.name + }.sortedBy { + it.name + }.forEach { task -> + sb.append(" ${task.name}\t\t${task.doc}\n") + } + } + + println(sb.toString()) + } + private fun runClasspathInterceptors(allProjects: List) { allProjects.forEach { runClasspathInterceptors(it.compileDependencies)