diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/AsciiArt.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/AsciiArt.kt index 34aa3745..bcd40d4c 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/AsciiArt.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/AsciiArt.kt @@ -75,20 +75,21 @@ class AsciiArt { return result } - private fun fill(n: Int) = StringBuffer().apply { repeat(n, { append(" ")})}.toString() - val defaultLog : (s: String) -> Unit = { log(1, " $it") } fun logBox(strings: List, bl: String = bottomLeft, br: String = bottomRight, - print: (String) -> Unit = defaultLog) { - box(strings, bl, br).forEach { - print(it) + indent: Int = 0): String { + return buildString { + box(strings, bl, br).forEach { + append(fill(indent)).append(it).append("\n") + } } } - fun logBox(s: String, bl: String = bottomLeft, br: String = bottomRight, print: (String) -> Unit = defaultLog) { - logBox(listOf(s), bl, br, print) - } + fun logBox(s: String, bl: String = bottomLeft, br: String = bottomRight, indent: Int = 0) + = logBox(listOf(s), bl, br, indent) + + fun fill(n: Int) = buildString { repeat(n, { append(" ")})}.toString() fun center(s: String, width: Int) : String { val diff = width - s.length @@ -139,23 +140,24 @@ class AsciiTable { } val vb = AsciiArt.verticalBar + fun build() : String { val formattedHeaders = headers.mapIndexed { index, s -> val s2 = col(widths[index], s) s2 }.joinToString(vb) - val result = buildString { + val result = StringBuffer().apply { append(AsciiArt.logBox(formattedHeaders, AsciiArt.bottomLeft2, AsciiArt.bottomRight2)) } var lineLength = 0 rows.forEachIndexed { index, row -> val formattedRow = row.mapIndexed { i, s -> col(widths[i], s) }.joinToString(vb) val line = vb + " " + formattedRow + " " + vb - AsciiArt.defaultLog(line) + result.append(line).append("\n") lineLength = line.length } - AsciiArt.defaultLog(AsciiArt.lowerBox(lineLength - 4)) + result.append(AsciiArt.lowerBox(lineLength - 4)) return result.toString() } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/ResolveDependency.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/ResolveDependency.kt index c8ee2020..d27afc0d 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/ResolveDependency.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/ResolveDependency.kt @@ -42,7 +42,7 @@ class ResolveDependency @Inject constructor( val seen = hashSetOf(dep.id) root.addChildren(findChildren(root, seen)) - AsciiArt.logBox(listOf(dep.id, url, dep.jarFile.get()).map { " $it" }) + log(1, AsciiArt.logBox(listOf(dep.id, url, dep.jarFile.get()).map { " $it" })) display(root.children) println("") diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BuildListeners.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BuildListeners.kt index 319e7bcb..1d666dee 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BuildListeners.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BuildListeners.kt @@ -80,15 +80,17 @@ class BuildListeners : IBuildListener, IBuildReportContributor { // if (timings.size > 1 && hasFailures) { val line = listOf(col1("Project"), col2("Build status"), col3("Time")) .joinToString(AsciiArt.verticalBar) - AsciiArt.logBox(listOf(line), AsciiArt.bottomLeft2, AsciiArt.bottomRight2) + val table = StringBuffer() + table.append(AsciiArt.logBox(listOf(line), AsciiArt.bottomLeft2, AsciiArt.bottomRight2, indent = 10)) projectStatuses.forEach { pair -> val projectName = pair.first.name val cl = listOf(col1(projectName), col2(pair.second.toString()), col3(formatMillisLeft(projectInfos[projectName]!!.durationMillis, 8))) .joinToString(AsciiArt.verticalBar) - log(1, " " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar) + table.append(" " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar + "\n") } - log(1, " " + AsciiArt.lowerBox(line.length)) + table.append(" " + AsciiArt.lowerBox(line.length)) + log(1, table.toString()) // } } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt index c84409bf..c8b2c944 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/DynamicGraph.kt @@ -276,10 +276,8 @@ class DynamicGraphExecutor(val graph : DynamicGraph, val factory: IThreadW table.width(20) } table.header("Time (sec)") - val header = StringBuffer().apply { - threadIds.keys.forEach { - table.header("Thread " + it.toString()) - } + threadIds.keys.forEach { + table.header("Thread " + it.toString()) } fun toSeconds(millis: Long) = (millis / 1000).toInt().toString() diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/SequentialProjectRunner.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/SequentialProjectRunner.kt index 9170d045..859f4a6d 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/SequentialProjectRunner.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/SequentialProjectRunner.kt @@ -34,7 +34,7 @@ class SequentialProjectRunner(val tasksByNames: (Project) -> ListMultimap - AsciiArt.logBox("Building ${project.name}") + log(1, AsciiArt.logBox("Building ${project.name}", indent = 5)) // Does the current project depend on any failed projects? val fp = project.dependsOn.filter { failedProjects.contains(it.name) }.map(Project::name)