mirror of https://github.com/sbt/sbt.git
only provide `dependencyGraph` / `asciiGraph` in sbt 0.13
This commit is contained in:
parent
dd6c1c4206
commit
279dea3514
|
|
@ -1,8 +1,13 @@
|
|||
ScriptedPlugin.scriptedSettings
|
||||
|
||||
libraryDependencies += "com.github.mdr" %% "ascii-graphs" % "0.0.3"
|
||||
libraryDependencies ++= {
|
||||
if (sbtVersion.value startsWith "0.13")
|
||||
Seq("com.github.mdr" %% "ascii-graphs" % "0.0.3")
|
||||
else
|
||||
Nil
|
||||
}
|
||||
|
||||
libraryDependencies += "org.specs2" %% "specs2" % "2.3.11" % "test"
|
||||
libraryDependencies += "org.specs2" %% "specs2-core" % "3.9.1" % "test"
|
||||
|
||||
scalacOptions ++= Seq("-deprecation", "-unchecked")
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ package net.virtualvoid.sbt.graph
|
|||
package rendering
|
||||
|
||||
import com.github.mdr.ascii.layout._
|
||||
import net.virtualvoid.sbt.graph.DependencyGraphKeys._
|
||||
import sbt.Keys._
|
||||
|
||||
object AsciiGraph {
|
||||
def asciiGraph(graph: ModuleGraph): String =
|
||||
|
|
@ -35,4 +37,24 @@ object AsciiGraph {
|
|||
val edges = moduleGraph.edges.toList.map { case (from, to) ⇒ (renderVertex(moduleGraph.module(from)), renderVertex(moduleGraph.module(to))) }
|
||||
Graph(vertices, edges)
|
||||
}
|
||||
|
||||
def asciiGraphSetttings = Seq[sbt.Def.Setting[_]](
|
||||
DependencyGraphKeys.asciiGraph := asciiGraph(moduleGraph.value),
|
||||
dependencyGraph := {
|
||||
val force = DependencyGraphSettings.shouldForceParser.parsed
|
||||
val log = streams.value.log
|
||||
if (force || moduleGraph.value.nodes.size < 15) {
|
||||
log.info(rendering.AsciiGraph.asciiGraph(moduleGraph.value))
|
||||
log.info("\n\n")
|
||||
log.info("Note: The old tree layout is still available by using `dependency-tree`")
|
||||
}
|
||||
|
||||
log.info(rendering.AsciiTree.asciiTree(moduleGraph.value))
|
||||
|
||||
if (!force) {
|
||||
log.info("\n")
|
||||
log.info("Note: The graph was estimated to be too big to display (> 15 nodes). Use `sbt 'dependency-graph --force'` (with the single quotes) to force graph display.")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2017 Johannes Rudolph
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.virtualvoid.sbt.graph
|
||||
package rendering
|
||||
|
||||
object AsciiGraph {
|
||||
def asciiGraphSetttings = Seq.empty[sbt.Def.Setting[_]]
|
||||
}
|
||||
|
|
@ -18,15 +18,11 @@ package net.virtualvoid.sbt.graph
|
|||
|
||||
import sbt._
|
||||
import Keys._
|
||||
|
||||
import CrossVersion._
|
||||
|
||||
import sbt.complete.Parser
|
||||
|
||||
import org.apache.ivy.core.resolve.ResolveOptions
|
||||
|
||||
import net.virtualvoid.sbt.graph.backend.{ IvyReport, SbtUpdateReport }
|
||||
import net.virtualvoid.sbt.graph.rendering.DagreHTML
|
||||
import net.virtualvoid.sbt.graph.rendering.{ AsciiGraph, DagreHTML }
|
||||
import net.virtualvoid.sbt.graph.util.IOUtil
|
||||
|
||||
object DependencyGraphSettings {
|
||||
|
|
@ -55,23 +51,6 @@ object DependencyGraphSettings {
|
|||
else graph
|
||||
},
|
||||
moduleGraphStore <<= moduleGraph storeAs moduleGraphStore triggeredBy moduleGraph,
|
||||
asciiGraph <<= moduleGraph map rendering.AsciiGraph.asciiGraph,
|
||||
dependencyGraph <<= InputTask(shouldForceParser) { force ⇒
|
||||
(force, moduleGraph, streams) map { (force, graph, streams) ⇒
|
||||
if (force || graph.nodes.size < 15) {
|
||||
streams.log.info(rendering.AsciiGraph.asciiGraph(graph))
|
||||
streams.log.info("\n\n")
|
||||
streams.log.info("Note: The old tree layout is still available by using `dependency-tree`")
|
||||
} else {
|
||||
streams.log.info(rendering.AsciiTree.asciiTree(graph))
|
||||
|
||||
if (!force) {
|
||||
streams.log.info("\n")
|
||||
streams.log.info("Note: The graph was estimated to be too big to display (> 15 nodes). Use `sbt 'dependency-graph --force'` (with the single quotes) to force graph display.")
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
asciiTree <<= moduleGraph map rendering.AsciiTree.asciiTree,
|
||||
dependencyTree <<= print(asciiTree),
|
||||
dependencyGraphMLFile <<= target / "dependencies-%s.graphml".format(config.toString),
|
||||
|
|
@ -101,7 +80,7 @@ object DependencyGraphSettings {
|
|||
streams.log.info(rendering.AsciiTree.asciiTree(GraphTransformations.reverseGraphStartingAt(graph, module)))
|
||||
}
|
||||
},
|
||||
licenseInfo <<= (moduleGraph, streams) map showLicenseInfo))
|
||||
licenseInfo <<= (moduleGraph, streams) map showLicenseInfo) ++ AsciiGraph.asciiGraphSetttings)
|
||||
|
||||
def ivyReportFunctionTask =
|
||||
(sbtVersion, target, projectID, ivyModule, appConfiguration, streams) map { (sbtV, target, projectID, ivyModule, config, streams) ⇒
|
||||
|
|
|
|||
Loading…
Reference in New Issue