From 095a3918f1a3817acba102a7d11d6b913de6eccf Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 24 Jul 2016 23:28:31 -0800 Subject: [PATCH 1/4] Formatting. --- src/main/kotlin/com/beust/kobalt/Main.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 5e2bd2cc..d3ba7113 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -199,7 +199,7 @@ private class Main @Inject constructor( // --checkVersions checkVersions.run(allProjects) } else if (args.download) { - // -- download + // --download updateKobalt.downloadKobalt() } else { // @@ -213,11 +213,13 @@ private class Main @Inject constructor( // Shutdown all plug-ins plugins.shutdownPlugins() + // Display timings if requested if (args.profiling) { log(1, "\nTIMINGS (SECONDS)") - log(1, "================\n") + log(1, "=================\n") runTargetResult.timings.sortedByDescending { it.durationMillis }.forEach { - log(1, String.format("%.2f", it.durationMillis.toDouble() / 1000) + " " + it.taskName) + log(1, String.format("%-6.2f", it.durationMillis.toDouble() / 1000) + + " " + it.taskName) } log(1, "\n") } From 5df0d01a212115ef4493048e3c3c436255e431a5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 25 Jul 2016 00:39:06 -0800 Subject: [PATCH 2/4] Refactor PomGenerator. --- .../kotlin/com/beust/kobalt/JarGenerator.kt | 2 +- .../main/kotlin/com/beust/kobalt/Variant.kt | 6 ++-- .../kotlin/com/beust/kobalt/api/Project.kt | 2 +- .../com/beust/kobalt/internal/ProjectInfo.kt | 2 +- .../com/beust/kobalt/maven/PomGenerator.kt | 31 ++++++++++++------- .../plugin/packaging/PackagingPlugin.kt | 2 +- .../kobalt/plugin/publish/PublishPlugin.kt | 2 +- .../kotlin/com/beust/kobalt/VariantTest.kt | 2 +- 8 files changed, 29 insertions(+), 20 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt index 8a2f5733..1146fd3b 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt @@ -125,7 +125,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager) // // Generate the manifest - // If manifest attributes were specified in the build file, use those to generate the manifest. Otherwise, + // If manifest attributes were specified in the build file, use those to generateAndSave the manifest. Otherwise, // try to find a META-INF/MANIFEST.MF and use that one if we find any. Otherwise, use the default manifest. // val manifest = diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Variant.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Variant.kt index ea3ea5f3..2bafde37 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Variant.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Variant.kt @@ -154,7 +154,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null, /** * Generate BuildConfig.java if requested. Also look up if any BuildConfig is defined on the current build type, - * product flavor or main project, and use them to generate any additional field (in that order to + * product flavor or main project, and use them to generateAndSave any additional field (in that order to * respect the priorities). Return the generated file if it was generated, null otherwise. */ fun maybeGenerateBuildConfig(project: Project, context: KobaltContext) : File? { @@ -163,7 +163,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null, if (buildConfigs.size > 0) { val pkg = project.packageName ?: project.group ?: throw KobaltException( - "packageName needs to be defined on the project in order to generate BuildConfig") + "packageName needs to be defined on the project in order to generateAndSave BuildConfig") val contributor = ActorUtils.selectAffinityActor(context.pluginInfo.buildConfigContributors, project) if (contributor != null) { @@ -178,7 +178,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null, log(2, "Generated ${outputDir.path}") return result } else { - throw KobaltException("Couldn't find a contributor to generate BuildConfig") + throw KobaltException("Couldn't find a contributor to generateAndSave BuildConfig") } } else { return null diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt index 7034fe25..374fb90d 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt @@ -46,7 +46,7 @@ open class Project( val testConfigs = arrayListOf() - // If one is specified by default, we only generate a BuildConfig, find a way to fix that + // If one is specified by default, we only generateAndSave a BuildConfig, find a way to fix that override var buildConfig : BuildConfig? = null // BuildConfig() val projectProperties = ProjectProperties() diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/ProjectInfo.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/ProjectInfo.kt index dccf9290..df865cec 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/ProjectInfo.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/ProjectInfo.kt @@ -12,7 +12,7 @@ import com.beust.kobalt.api.Project interface IBuildConfig { /** * If at least one build config was found either on the project or the variant, this function - * will be used to generate the BuildConfig file with the correct language. + * will be used to generateAndSave the BuildConfig file with the correct language. */ fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, variant: Variant, buildConfigs: List) : String diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt index a7c11320..8f349c99 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt @@ -18,7 +18,25 @@ class PomGenerator @Inject constructor(@Assisted val project: Project) { fun create(project: Project) : PomGenerator } - fun generate() { + /** + * Generate the POM file and save it. + */ + fun generateAndSave() { + val buildDir = KFiles.makeDir(project.directory, project.buildDirectory) + val outputDir = KFiles.makeDir(buildDir.path, "libs") + val NO_CLASSIFIER = null + val mavenId = MavenId.create(project.group!!, project.artifactId!!, project.packaging, NO_CLASSIFIER, + project.version!!) + val pomFile = SimpleDep(mavenId).toPomFileName() + val outputFile = File(outputDir, pomFile) + outputFile.writeText(generate(), Charset.defaultCharset()) + log(1, " Created $outputFile") + } + + /** + * @return the text content of the POM file. + */ + fun generate() : String { requireNotNull(project.version, { "version mandatory on project ${project.name}" }) requireNotNull(project.group, { "group mandatory on project ${project.name}" }) requireNotNull(project.artifactId, { "artifactId mandatory on project ${project.name}" }) @@ -60,15 +78,6 @@ class PomGenerator @Inject constructor(@Assisted val project: Project) { val s = StringWriter() MavenXpp3Writer().write(s, pom) - - val buildDir = KFiles.makeDir(project.directory, project.buildDirectory) - val outputDir = KFiles.makeDir(buildDir.path, "libs") - val NO_CLASSIFIER = null - val mavenId = MavenId.create(project.group!!, project.artifactId!!, project.packaging, NO_CLASSIFIER, - project.version!!) - val pomFile = SimpleDep(mavenId).toPomFileName() - val outputFile = File(outputDir, pomFile) - outputFile.writeText(s.toString(), Charset.defaultCharset()) - log(1, " Created $outputFile") + return s.toString() } } 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 9d33bb2e..82490802 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt @@ -77,7 +77,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana packageConfig.wars.forEach { warGenerator.generateWar(packageConfig.project, context, it) } packageConfig.zips.forEach { zipGenerator.generateZip(packageConfig.project, context, it) } if (packageConfig.generatePom) { - pomFactory.create(project).generate() + pomFactory.create(project).generateAndSave() } } TaskResult() diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt index 036dba5e..9032b056 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt @@ -41,7 +41,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P @Suppress("UNUSED_FUNCTION_LITERAL") @Task(name = TASK_GENERATE_POM, description = "Generate the .pom file", dependsOn = arrayOf("assemble")) fun taskGeneratePom(project: Project): TaskResult { - factory.create(project).generate() + factory.create(project).generateAndSave() return TaskResult() } diff --git a/src/test/kotlin/com/beust/kobalt/VariantTest.kt b/src/test/kotlin/com/beust/kobalt/VariantTest.kt index 44ec202c..054541b5 100644 --- a/src/test/kotlin/com/beust/kobalt/VariantTest.kt +++ b/src/test/kotlin/com/beust/kobalt/VariantTest.kt @@ -35,7 +35,7 @@ class VariantTest : KobaltTest() { ) @Test(dataProvider = "projectVariants", description = - "Make sure we generate the correct dynamic tasks based on the product flavor and build types.") + "Make sure we generateAndSave the correct dynamic tasks based on the product flavor and build types.") fun taskNamesShouldWork(expected: Set, project: Project) { val variantNames = HashSet(Variant.allVariants(project).map { it.toTask("compile") }) Assert.assertEquals(variantNames, expected) From b02ba388da96efe42af02d55363605dfd8f40ee8 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 25 Jul 2016 00:41:42 -0800 Subject: [PATCH 3/4] Introduce KobaltContext#filefor(id). --- .../com/beust/kobalt/api/KobaltContext.kt | 38 ++++++++ .../com/beust/kobalt/maven/aether/Aether.kt | 87 ++++++++----------- .../com/beust/kobalt/app/BuildFileCompiler.kt | 6 +- 3 files changed, 80 insertions(+), 51 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/KobaltContext.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/KobaltContext.kt index 1b4ee15c..a503e9de 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/KobaltContext.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/KobaltContext.kt @@ -1,12 +1,16 @@ package com.beust.kobalt.api import com.beust.kobalt.Args +import com.beust.kobalt.KobaltException import com.beust.kobalt.Plugins import com.beust.kobalt.Variant import com.beust.kobalt.internal.IncrementalManager import com.beust.kobalt.internal.KobaltSettings import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.maven.DependencyManager +import com.beust.kobalt.maven.MavenId +import com.beust.kobalt.maven.SimpleDep +import com.beust.kobalt.maven.aether.KobaltAether import com.beust.kobalt.misc.KobaltExecutors import java.io.File @@ -22,6 +26,39 @@ class KobaltContext(val args: Args) { fun findPlugin(name: String) = Plugins.findPlugin(name) + /** + * Files that can be resolved in the local cache. + */ + enum class FileType { JAR, POM, SOURCES, JAVADOC, OTHER } + + /** + * @param{id} is the Maven coordinate (e.g. "org.testng:testng:6.9.11"). If you are looking for a file + * that is not described by the enum (e.g. "aar"), use OTHER and make sure your @param{id} contains + * the fully qualified id (e.g. "com.example:example::aar:1.0"). + */ + fun fileFor(id: String, fileType: FileType) : File { + val dep = SimpleDep(MavenId.create(id)) + fun toQualifier(dep: SimpleDep, ext: String, qualifier: String?) = + dep.groupId + ":" + dep.artifactId + + ":$ext" + + (if (qualifier != null) ":$qualifier" else "") + + ":" + dep.version + val fullId = + when (fileType) { + FileType.JAR -> toQualifier(dep, "jar", null) + FileType.POM -> toQualifier(dep, "pom", null) + FileType.SOURCES -> toQualifier(dep, "", "sources") + FileType.JAVADOC -> toQualifier(dep, "", "javadoc") + FileType.OTHER -> id + } + val resolved = aether.resolveToArtifact(fullId) + if (resolved != null) { + return resolved.artifact.file + } else { + throw KobaltException("Couldn't resolve $id") + } + } + /** All the projects that are being built during this run */ val allProjects = arrayListOf() @@ -37,6 +74,7 @@ class KobaltContext(val args: Args) { lateinit var executors: KobaltExecutors lateinit var settings: KobaltSettings lateinit var incrementalManager: IncrementalManager + lateinit var aether: KobaltAether } class InternalContext { diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Aether.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Aether.kt index 51999be7..cb9f6ced 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Aether.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/Aether.kt @@ -45,10 +45,10 @@ class KobaltAether @Inject constructor (val settings: KobaltSettings, val aether /** * @return the latest artifact for the given group and artifactId. */ - fun latestArtifact(group: String, artifactId: String, extension: String = "jar") : DependencyResult - = aether.latestArtifact(group, artifactId, extension).let { - DependencyResult(AetherDependency(it.artifact), it.repository.toString()) - } + fun latestArtifact(group: String, artifactId: String, extension: String = "jar"): DependencyResult + = aether.latestArtifact(group, artifactId, extension).let { + DependencyResult(AetherDependency(it.artifact), it.repository.toString()) + } fun resolveAll(id: String, isTest: Boolean): List { val results = aether.resolve(DefaultArtifact(id), isTest) @@ -57,23 +57,32 @@ class KobaltAether @Inject constructor (val settings: KobaltSettings, val aether fun resolve(id: String, isTest: Boolean = false): DependencyResult { log(ConsoleRepositoryListener.LOG_LEVEL, "Resolving $id") - val results = aether.resolve(DefaultArtifact(MavenId.toKobaltId(id)), isTest) - if (results.size > 0) { - return DependencyResult(AetherDependency(results[0].artifact), results[0].repository.toString()) + val result = resolveToArtifact(id, isTest) + if (result != null) { + return DependencyResult(AetherDependency(result.artifact), result.repository.toString()) } else { throw KobaltException("Couldn't resolve $id") } } -} + fun resolveToArtifact(id: String, isTest: Boolean = false): ArtifactResult? { + log(ConsoleRepositoryListener.LOG_LEVEL, "Resolving $id") + val results = aether.resolve(DefaultArtifact(MavenId.toKobaltId(id)), isTest) + if (results.size > 0) { + return results[0] + } else { + return null + } + } -class ExcludeOptionalDependencyFilter: DependencyFilter { - override fun accept(node: DependencyNode?, p1: MutableList?): Boolean { + class ExcludeOptionalDependencyFilter : DependencyFilter { + override fun accept(node: DependencyNode?, p1: MutableList?): Boolean { // val result = node != null && ! node.dependency.isOptional - val accept1 = node == null || node.artifact.artifactId != "srczip" - val accept2 = node != null && ! node.dependency.isOptional - val result = accept1 && accept2 - return result + val accept1 = node == null || node.artifact.artifactId != "srczip" + val accept2 = node != null && !node.dependency.isOptional + val result = accept1 && accept2 + return result + } } } @@ -82,15 +91,15 @@ class Aether(val localRepo: File, val settings: KobaltSettings, val eventBus: Ev private val system = Booter.newRepositorySystem() private val session = Booter.newRepositorySystemSession(system, localRepo, settings, eventBus) private val classpathFilter = AndDependencyFilter( - ExcludeOptionalDependencyFilter(), + KobaltAether.ExcludeOptionalDependencyFilter(), DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE), DependencyFilterUtils.classpathFilter(JavaScopes.TEST)) private val testClasspathFilter = AndDependencyFilter( - ExcludeOptionalDependencyFilter(), + KobaltAether.ExcludeOptionalDependencyFilter(), DependencyFilterUtils.classpathFilter(JavaScopes.TEST)) - private val kobaltRepositories : List + private val kobaltRepositories: List get() = Kobalt.repos.map { RemoteRepository.Builder("maven", "default", it.url) // .setSnapshotPolicy(RepositoryPolicy(false, null, null)) @@ -102,7 +111,7 @@ class Aether(val localRepo: File, val settings: KobaltSettings, val eventBus: Ev } } - private fun collectRequest(artifact: Artifact, isTest: Boolean) : CollectRequest { + private fun collectRequest(artifact: Artifact, isTest: Boolean): CollectRequest { with(CollectRequest()) { root = Dependency(artifact, if (isTest) JavaScopes.TEST else JavaScopes.COMPILE) repositories = kobaltRepositories @@ -111,7 +120,7 @@ class Aether(val localRepo: File, val settings: KobaltSettings, val eventBus: Ev } } - fun latestArtifact(group: String, artifactId: String, extension: String = "jar") : ArtifactResult { + fun latestArtifact(group: String, artifactId: String, extension: String = "jar"): ArtifactResult { val artifact = DefaultArtifact(group, artifactId, extension, "(0,]") val resolved = resolveVersion(artifact) if (resolved != null) { @@ -119,7 +128,7 @@ class Aether(val localRepo: File, val settings: KobaltSettings, val eventBus: Ev resolved.highestVersion.toString()) val artifactResult = resolve(newArtifact) if (artifactResult != null && artifactResult.size > 0) { - return artifactResult[0] + return artifactResult[0] } else { throw KobaltException("Couldn't find latest artifact for $group:$artifactId") } @@ -134,32 +143,8 @@ class Aether(val localRepo: File, val settings: KobaltSettings, val eventBus: Ev return result } - private fun oldResolveVErsion() { -// val artifact = DefaultArtifact(a.groupId, a.artifactId, null, "[0,)") -// val r = system.resolveMetadata(session, kobaltRepositories.map { -// MetadataRequest(metadata, it, null).apply { -// isFavorLocalRepository = false -// } -// }) - -// val metadata = DefaultMetadata(artifact.groupId, artifact.artifactId, "maven-metadata.xml", -// org.eclipse.aether.metadata.Metadata.Nature.RELEASE) -// -// kobaltRepositories.forEach { -// val request = MetadataRequest(metadata, it, null).apply { -// isFavorLocalRepository = false -// } -// val md = system.resolveMetadata(session, listOf(request)) -// if (artifact.groupId.contains("org.testng")) { -// println("DONOTCOMMIT") -// } -// println("Repo: $it " + md) -// } - - } - fun resolve(artifact: Artifact, isTest: Boolean = false): List { - fun manageException(ex: Exception, artifact: Artifact) : List { + fun manageException(ex: Exception, artifact: Artifact): List { if (artifact.extension == "pom") { // Only display a warning for .pom files. Not resolving a .jar or other artifact // is not necessarily an error as long as there is a pom file. @@ -186,10 +171,11 @@ class Aether(val localRepo: File, val settings: KobaltSettings, val eventBus: Ev = system.collectDependencies(session, collectRequest(artifact, isTest)) } -class AetherDependency(val artifact: Artifact): IClasspathDependency, Comparable { +class AetherDependency(val artifact: Artifact) : IClasspathDependency, Comparable { val aether: Aether get() = Kobalt.INJECTOR.getInstance(Aether::class.java) - constructor(node: DependencyNode) : this(node.artifact) {} + constructor(node: DependencyNode) : this(node.artifact) { + } override val id: String = toId(artifact) @@ -228,13 +214,13 @@ class AetherDependency(val artifact: Artifact): IClasspathDependency, Comparable } } - override fun directDependencies() : List { + override fun directDependencies(): List { val result = arrayListOf() val deps = aether.directDependencies(artifact) if (deps != null) { - if (! deps.root.dependency.optional) { + if (!deps.root.dependency.optional) { deps.root.children.forEach { - if (! it.dependency.isOptional) { + if (!it.dependency.isOptional) { result.add(AetherDependency(it.artifact)) } else { log(ConsoleRepositoryListener.LOG_LEVEL, "Skipping optional dependency " + deps.root.artifact) @@ -290,3 +276,4 @@ fun main(argv: Array) { // // println("Artifact: " + d) } + diff --git a/src/main/kotlin/com/beust/kobalt/app/BuildFileCompiler.kt b/src/main/kotlin/com/beust/kobalt/app/BuildFileCompiler.kt index aac58c59..659ff847 100644 --- a/src/main/kotlin/com/beust/kobalt/app/BuildFileCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/app/BuildFileCompiler.kt @@ -14,6 +14,8 @@ import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.internal.build.BuildFile import com.beust.kobalt.internal.build.VersionFile import com.beust.kobalt.maven.DependencyManager +import com.beust.kobalt.maven.LocalRepo +import com.beust.kobalt.maven.aether.KobaltAether import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.log @@ -33,7 +35,8 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b @Assisted val pluginInfo: PluginInfo, val files: KFiles, val plugins: Plugins, val dependencyManager: DependencyManager, val pluginProperties: PluginProperties, val executors: KobaltExecutors, val buildScriptUtil: BuildScriptUtil, val settings: KobaltSettings, - val incrementalManagerFactory: IncrementalManager.IFactory, val args: Args) { + val incrementalManagerFactory: IncrementalManager.IFactory, val args: Args, + val aether: KobaltAether) { interface IFactory { fun create(@Assisted("buildFiles") buildFiles: List, pluginInfo: PluginInfo) : BuildFileCompiler @@ -53,6 +56,7 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b context.executors = executors context.settings = settings context.incrementalManager = incrementalManagerFactory.create() + context.aether = aether Kobalt.context = context // From e96a3a52e46569e2e40d1e3a211c05f3149b53a6 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 25 Jul 2016 11:58:47 -0700 Subject: [PATCH 4/4] Prettyfied --profiling output --- src/main/kotlin/com/beust/kobalt/Main.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index d3ba7113..4bdc5547 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -215,10 +215,9 @@ private class Main @Inject constructor( // Display timings if requested if (args.profiling) { - log(1, "\nTIMINGS (SECONDS)") - log(1, "=================\n") + log(1, "\n" + AsciiArt.horizontalSingleLine + " Timings (in seconds)") runTargetResult.timings.sortedByDescending { it.durationMillis }.forEach { - log(1, String.format("%-6.2f", it.durationMillis.toDouble() / 1000) + log(1, String.format("%1$10.2f", it.durationMillis.toDouble() / 1000) + " " + it.taskName) } log(1, "\n")