sbt.internal.graph.rendering.AsciiTree.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of main_2.12 Show documentation
Show all versions of main_2.12 Show documentation
sbt is an interactive build tool
The newest version!
/*
* sbt
* Copyright 2023, Scala center
* Copyright 2011 - 2022, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* Licensed under Apache License 2.0 (see LICENSE)
*/
package sbt
package internal
package graph
package rendering
import sbt.internal.util.Terminal.red
object AsciiTree {
def asciiTree(graph: ModuleGraph, graphWidth: Int): String = {
val deps = graph.dependencyMap
// there should only be one root node (the project itself)
val roots = graph.roots
roots
.map { root =>
Graph
.toAscii[Module](
root,
node => deps.getOrElse(node.id, Seq.empty[Module]),
displayModule,
graphWidth
)
}
.mkString("\n")
}
def displayModule(module: Module): String =
red(
module.id.idString +
module.extraInfo +
module.error.map(" (error: " + _ + ")").getOrElse("") +
module.evictedByVersion.map(v => s" (evicted by: $v)").getOrElse(""),
module.hadError
)
}