mirror of https://github.com/sbt/sbt.git
Add new SBT global setting asciiGraphWidth
This setting controls the maximum width of the ASCII graphs printed by commands like `inspect tree`. Default value corresponds to the previously hardcoded value of 40 characters.
This commit is contained in:
parent
cfecf1f6b9
commit
982a7c8724
|
|
@ -1,2 +1,3 @@
|
|||
target/
|
||||
__pycache__
|
||||
.idea
|
||||
|
|
|
|||
|
|
@ -362,7 +362,8 @@ object Defaults extends BuildCommon {
|
|||
|
||||
private[this] lazy val configGlobal = globalDefaults(Seq(
|
||||
initialCommands :== "",
|
||||
cleanupCommands :== ""
|
||||
cleanupCommands :== "",
|
||||
asciiGraphWidth :== 40
|
||||
))
|
||||
|
||||
lazy val projectTasks: Seq[Setting[_]] = Seq(
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ object Keys {
|
|||
val compileOrder = SettingKey[CompileOrder]("compile-order", "Configures the order in which Java and sources within a single compilation are compiled. Valid values are: JavaThenScala, ScalaThenJava, or Mixed.", BPlusSetting)
|
||||
val initialCommands = SettingKey[String]("initial-commands", "Initial commands to execute when starting up the Scala interpreter.", AMinusSetting)
|
||||
val cleanupCommands = SettingKey[String]("cleanup-commands", "Commands to execute before the Scala interpreter exits.", BMinusSetting)
|
||||
val asciiGraphWidth = SettingKey[Int]("asciiGraphWidth", "Determines maximum width of the settings graph in ASCII mode", AMinusSetting)
|
||||
val compileOptions = TaskKey[CompileOptions]("compile-options", "Collects basic options to configure compilers", DTask)
|
||||
val compileInputs = TaskKey[Inputs]("compile-inputs", "Collects all inputs needed for compilation.", DTask)
|
||||
val scalaHome = SettingKey[Option[File]]("scala-home", "If Some, defines the local Scala installation to use for compilation, running, and testing.", ASetting)
|
||||
|
|
|
|||
|
|
@ -534,8 +534,8 @@ object Project extends ProjectExtra {
|
|||
printScopes("Delegates", delegates(structure, scope, key)) +
|
||||
printScopes("Related", related, 10)
|
||||
}
|
||||
def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[_])(implicit display: Show[ScopedKey[_]]): SettingGraph =
|
||||
SettingGraph(structure, basedir, scoped, 0)
|
||||
def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[_], maxGraphWidth: Int)(implicit display: Show[ScopedKey[_]]): SettingGraph =
|
||||
SettingGraph(structure, basedir, scoped, 0, maxGraphWidth)
|
||||
def graphSettings(structure: BuildStructure, basedir: File)(implicit display: Show[ScopedKey[_]]): Unit = {
|
||||
def graph(actual: Boolean, name: String) = graphSettings(structure, actual, name, new File(basedir, name + ".dot"))
|
||||
graph(true, "actual_dependencies")
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ object Inspect {
|
|||
Project.details(structure, actual, sk.scope, sk.key)
|
||||
case DependencyTreeMode =>
|
||||
val basedir = new File(Project.session(s).current.build)
|
||||
Project.settingGraph(structure, basedir, sk).dependsAscii
|
||||
Project.settingGraph(structure, basedir, sk, get(sbt.Keys.asciiGraphWidth)).dependsAscii
|
||||
case UsesMode =>
|
||||
Project.showUses(Project.usedBy(structure, true, sk.key))
|
||||
case DefinitionsMode =>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import Predef.{ any2stringadd => _, _ }
|
|||
import sbt.io.IO
|
||||
|
||||
object SettingGraph {
|
||||
def apply(structure: BuildStructure, basedir: File, scoped: ScopedKey[_], generation: Int)(implicit display: Show[ScopedKey[_]]): SettingGraph =
|
||||
def apply(structure: BuildStructure, basedir: File, scoped: ScopedKey[_], generation: Int, graphMaxWidth: Int)(implicit display: Show[ScopedKey[_]]): SettingGraph =
|
||||
{
|
||||
val cMap = flattenLocals(compiled(structure.settings, false)(structure.delegates, structure.scopeLocal, display))
|
||||
def loop(scoped: ScopedKey[_], generation: Int): SettingGraph =
|
||||
|
|
@ -28,7 +28,8 @@ object SettingGraph {
|
|||
SettingGraph(display(scoped), definedIn,
|
||||
Project.scopedKeyData(structure, scope, key),
|
||||
key.description, basedir,
|
||||
depends map { (x: ScopedKey[_]) => loop(x, generation + 1) })
|
||||
depends map { (x: ScopedKey[_]) => loop(x, generation + 1) },
|
||||
graphMaxWidth)
|
||||
}
|
||||
loop(scoped, generation)
|
||||
}
|
||||
|
|
@ -40,7 +41,8 @@ case class SettingGraph(
|
|||
data: Option[ScopedKeyData[_]],
|
||||
description: Option[String],
|
||||
basedir: File,
|
||||
depends: Set[SettingGraph]
|
||||
depends: Set[SettingGraph],
|
||||
graphMaxWidth: Int
|
||||
) {
|
||||
def dataString: String =
|
||||
data map { d =>
|
||||
|
|
@ -53,7 +55,8 @@ case class SettingGraph(
|
|||
def dependsAscii: String = Graph.toAscii(
|
||||
this,
|
||||
(x: SettingGraph) => x.depends.toSeq.sortBy(_.name),
|
||||
(x: SettingGraph) => "%s = %s" format (x.definedIn getOrElse { "" }, x.dataString)
|
||||
(x: SettingGraph) => "%s = %s" format (x.definedIn getOrElse { "" }, x.dataString),
|
||||
graphMaxWidth
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -63,8 +66,7 @@ object Graph {
|
|||
// [info] | +-baz
|
||||
// [info] |
|
||||
// [info] +-quux
|
||||
def toAscii[A](top: A, children: A => Seq[A], display: A => String): String = {
|
||||
val defaultWidth = 40
|
||||
def toAscii[A](top: A, children: A => Seq[A], display: A => String, defaultWidth: Int): String = {
|
||||
// TODO: Fix JLine
|
||||
val maxColumn = math.max( /*JLine.usingTerminal(_.getWidth)*/ 0, defaultWidth) - 8
|
||||
val twoSpaces = " " + " " // prevent accidentally being converted into a tab
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
[@RomanIakovlev]: https://github.com/RomanIakovlev
|
||||
|
||||
### Fixes with compatibility implications
|
||||
|
||||
### Improvements
|
||||
|
||||
Add new global setting `asciiGraphWidth` that controls the maximum width of the ASCII graphs printed by commands like `inspect tree`. Default value corresponds to the previously hardcoded value of 40 characters. By [@RomanIakovlev][@RomanIakovlev].
|
||||
|
||||
### Bug fixes
|
||||
Loading…
Reference in New Issue