diff --git a/README.md b/README.md index 5f1bb48e3..ab20fbaa2 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ This plugin is an auto-plugin which will be automatically enabled starting from * `dependencyTree`: Shows an ASCII tree representation of the project's dependencies * `dependencyBrowseGraph`: Opens a browser window with a visualization of the dependency graph (courtesy of graphlib-dot + dagre-d3). * `dependencyGraph`: Shows an ASCII graph of the project's dependencies on the sbt console + * `dependencyList`: Shows a flat list of all transitive dependencies on the sbt console (sorted by organization and name) * `whatDependsOn `: Find out what depends on an artifact. Shows a reverse dependency tree for the selected module. * `dependencyLicenseInfo`: show dependencies grouped by declared license diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphKeys.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphKeys.scala index e0159a4f0..a5b33d26e 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphKeys.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphKeys.scala @@ -52,7 +52,9 @@ trait DependencyGraphKeys { val asciiTree = TaskKey[String]("dependency-tree-string", "Returns a string containing an ascii tree representation of the dependency graph for a project") val dependencyTree = TaskKey[Unit]("dependency-tree", - "Prints the ascii tree to the console") + "Prints an ascii tree of all the dependencies to the console") + val dependencyList = TaskKey[Unit]("dependency-list", + "Prints a list of all dependencies to the console") val ivyReportFunction = TaskKey[String ⇒ File]("ivy-report-function", "A function which returns the file containing the ivy report from the ivy cache for a given configuration") val ivyReport = TaskKey[File]("ivy-report", diff --git a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala index 98ca55d39..776eef144 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/DependencyGraphSettings.scala @@ -86,6 +86,7 @@ object DependencyGraphSettings { java.awt.Desktop.getDesktop.browse(uri) uri }, + dependencyList <<= (moduleGraph, streams).map((graph, streams) ⇒ streams.log.info(rendering.FlatList.render(graph, _.id.idString))), dependencyDotHeader := """digraph "dependency-graph" { | graph[rankdir="LR"] | edge [ diff --git a/src/main/scala/net/virtualvoid/sbt/graph/rendering/FlatList.scala b/src/main/scala/net/virtualvoid/sbt/graph/rendering/FlatList.scala new file mode 100644 index 000000000..eb26cff87 --- /dev/null +++ b/src/main/scala/net/virtualvoid/sbt/graph/rendering/FlatList.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2016 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 FlatList { + def render(graph: ModuleGraph, display: Module ⇒ String): String = + graph.modules.values.toSeq + .distinct + .filterNot(_.isEvicted) + .sortBy(m ⇒ (m.id.organisation, m.id.name)) + .map(display) + .mkString("\n") +}