mirror of https://github.com/sbt/sbt.git
fix #32: provide Graph for all sbt versions and don't rely on jline terminal width being > 0
This commit is contained in:
parent
4cc1309b18
commit
3a8a08a2a2
|
|
@ -0,0 +1 @@
|
|||
This is a maintenance release fixing an exception when generating graphs without a terminal [#32](https://github.com/jrudolph/sbt-dependency-graph/issues/32).
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
package net.virtualvoid.sbt.graph
|
||||
package sbt
|
||||
|
||||
import sbt._
|
||||
import net.virtualvoid.sbt.graph.Plugin._
|
||||
import Keys._
|
||||
|
||||
import Plugin.ignoreMissingUpdate
|
||||
|
||||
object Compat {
|
||||
object SbtDependencyGraphCompat {
|
||||
/**
|
||||
* This is copied directly from sbt/main/Defaults.java and then changed to update the UpdateConfiguration
|
||||
* to ignore missing artifacts.
|
||||
|
|
@ -20,4 +18,6 @@ object Compat {
|
|||
|
||||
import complete.DefaultParsers._
|
||||
lazy val StringBasic = NotSpaceClass.*.string
|
||||
}
|
||||
|
||||
def getTerminalWidth: Int = jline.Terminal.getTerminal.getTerminalWidth
|
||||
}
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
package net.virtualvoid.sbt.graph
|
||||
package sbt
|
||||
|
||||
import sbt._
|
||||
import net.virtualvoid.sbt.graph.Plugin._
|
||||
import Keys._
|
||||
|
||||
import Plugin.ignoreMissingUpdate
|
||||
|
||||
object Compat {
|
||||
object SbtDependencyGraphCompat {
|
||||
/**
|
||||
* This is copied directly from sbt/main/Defaults.java and then changed to update the UpdateConfiguration
|
||||
* to ignore missing artifacts.
|
||||
|
|
@ -19,4 +17,6 @@ object Compat {
|
|||
|
||||
Classpaths.cachedUpdate(cacheDirectory / "update", Project.display(ref), module, missingOkConfig, Some(si), skip = skip, force = isRoot, depsUpdated = depsUpdated, log = s.log)
|
||||
} tag(Tags.Update, Tags.Network)
|
||||
}
|
||||
|
||||
def getTerminalWidth: Int = JLine.usingTerminal(_.getTerminalWidth)
|
||||
}
|
||||
|
|
@ -3,7 +3,9 @@
|
|||
*
|
||||
* Copied from sbt 0.12 source code
|
||||
*/
|
||||
package sbt
|
||||
package net.virtualvoid.sbt.graph
|
||||
|
||||
import sbt.SbtDependencyGraphCompat
|
||||
|
||||
object Graph
|
||||
{
|
||||
|
|
@ -12,8 +14,10 @@ object Graph
|
|||
// [info] | +-baz
|
||||
// [info] |
|
||||
// [info] +-quux
|
||||
def toAscii[A](top: A, children: A => Seq[A], display: A => String): String = {
|
||||
val maxColumn = jline.Terminal.getTerminal.getTerminalWidth - 8
|
||||
def toAscii[A](top: A,
|
||||
children: A => Seq[A],
|
||||
display: A => String,
|
||||
maxColumn: Int = defaultColumnSize): String = {
|
||||
val twoSpaces = " " + " " // prevent accidentally being converted into a tab
|
||||
def limitLine(s: String): String =
|
||||
if (s.length > maxColumn) s.slice(0, maxColumn - 2) + ".."
|
||||
|
|
@ -40,4 +44,10 @@ object Graph
|
|||
|
||||
toAsciiLines(top, 0).mkString("\n")
|
||||
}
|
||||
|
||||
def defaultColumnSize: Int = {
|
||||
val termWidth = SbtDependencyGraphCompat.getTerminalWidth
|
||||
if (termWidth > 20) termWidth - 8
|
||||
else 80 // ignore termWidth
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ import java.io.File
|
|||
import collection.mutable.HashMap
|
||||
import collection.mutable.MultiMap
|
||||
import collection.mutable.{Set => MSet}
|
||||
import sbt.{ConsoleLogger, Graph}
|
||||
import sbt.ConsoleLogger
|
||||
import xml.{NodeSeq, Document, XML, Node}
|
||||
import com.github.mdr.ascii.layout
|
||||
import layout._
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ object Plugin extends sbt.Plugin {
|
|||
(c: String) => file("%s/cache/%s-%s-%s.xml" format (home, projectID.organization, crossName(ivyModule), c))
|
||||
}
|
||||
},
|
||||
Compat.ignoreMissingUpdateT,
|
||||
SbtDependencyGraphCompat.ignoreMissingUpdateT,
|
||||
filterScalaLibrary in Global := true
|
||||
) ++ Seq(Compile, Test, Runtime, Provided, Optional).flatMap(ivyReportForConfig)
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ object Plugin extends sbt.Plugin {
|
|||
val graph = loadFromContext(moduleGraphStore, ctx, state) getOrElse ModuleGraph(Nil, Nil)
|
||||
|
||||
import complete.DefaultParsers._
|
||||
import Compat._
|
||||
import SbtDependencyGraphCompat._
|
||||
|
||||
def moduleFrom(modules: Seq[ModuleId]) =
|
||||
modules.map { m =>
|
||||
|
|
|
|||
Loading…
Reference in New Issue