From ff8d9b82b02295a437ec39469efeaab375228fe5 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 26 Aug 2013 12:53:03 +0200 Subject: [PATCH 1/6] README: separate tasks & settings and add configuration example, fixes #37 Also setting names were converted to Scala syntax. --- README.md | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e86656d92..bfdfde268 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ object MyBuild extends Build { Check out the [example project] for a skeleton build setup. -Tasks & Settings ----------------- +Tasks +----- * `dependency-graph`: Shows an ASCII graph of the project's dependencies on the sbt console * `dependency-graph-ml`: Generates a .graphml file with the project's dependencies to `target/dependencies-.graphml`. @@ -50,14 +50,6 @@ Tasks & Settings * `what-depends-on `: Find out what depends on an artifact. Shows a reverse dependency tree for the selected module. * `dependency-license-info`: show dependencies grouped by declared license - * `filter-scala-library`: Defines if the scala library should be excluded from the output of the dependency-* functions. - If `true`, instead of showing the dependency `"[S]"` is appended to the artifact name. Set to `false` if - you want the scala-library dependency to appear in the output. (default: true) - * `dependency-graph-ml-file`: a setting which allows configuring the output path of `dependency-graph-ml`. - * `dependency-dot-file`: a setting which allows configuring the output path of `dependency-dot`. - * `dependency-dot-header`: a setting to customize the header of the dot file (e.g. to set your preferred node shapes). - * `dependency-dot-nodes-label`: defines the formation of a node label - (default set to `[organisation]
[name]
[version]`) * `ivy-report`: let's ivy generate the resolution report for you project. Use `show ivy-report` for the filename of the generated report @@ -65,6 +57,27 @@ All tasks can be scoped to a configuration to get the report for a specific conf for example, prints the dependencies in the `test` configuration. If you don't specify any configuration, `compile` is assumed as usual. + +Configuration settings +---------------------- + + * `filterScalaLibrary`: Defines if the scala library should be excluded from the output of the dependency-* functions. + If `true`, instead of showing the dependency `"[S]"` is appended to the artifact name. Set to `false` if + you want the scala-library dependency to appear in the output. (default: true) + * `dependencyGraphMLFile`: a setting which allows configuring the output path of `dependency-graph-ml`. + * `dependencyDotFile`: a setting which allows configuring the output path of `dependency-dot`. + * `dependencyDotHeader`: a setting to customize the header of the dot file (e.g. to set your preferred node shapes). + * `dependencyDotNodeLabel`: defines the format of a node label + (default set to `[organisation]
[name]
[version]`) + +E.g. in `build.sbt` you can change configuration settings like this: + +```scala +filterScalaLibrary := false // include scala library in output + +dependencyDotFile := file("dependencies.dot") //render dot file to `./dependencies.dot` +``` + Standalone usage ---------------- From 90500a9f9b9775debdc4f07adb503d5edb39cdc3 Mon Sep 17 00:00:00 2001 From: "Paolo G. Giarrusso" Date: Tue, 27 Aug 2013 15:21:37 +0200 Subject: [PATCH 2/6] Also mention 0.13 0.13 release announcement mentions this plugin, in this version: https://groups.google.com/d/msg/simple-build-tool/0AGST5qPbzw/CrN1sJ6ut-AJ Hence, the README should be updated as well. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bfdfde268..def8eb3d0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Visualize your project's dependencies. How To Use ---------- -For sbt 0.11/0.12, add sbt-dependency-graph as a dependency in `project/plugins.sbt`: +For sbt 0.11/0.12/0.13, add sbt-dependency-graph as a dependency in `project/plugins.sbt`: ```scala addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4") From 1f65c0c86bafac769a97b73a5d1c4cc43523f120 Mon Sep 17 00:00:00 2001 From: 2beaucoup Date: Wed, 15 Jan 2014 17:07:50 +0100 Subject: [PATCH 3/6] only match scala lib by org/name --- .../virtualvoid/sbt/graph/IvyGraphMLDependencies.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/net/virtualvoid/sbt/graph/IvyGraphMLDependencies.scala b/src/main/scala/net/virtualvoid/sbt/graph/IvyGraphMLDependencies.scala index ab80dced7..3044b13c0 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/IvyGraphMLDependencies.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/IvyGraphMLDependencies.scala @@ -118,10 +118,11 @@ object IvyGraphMLDependencies extends App { } def ignoreScalaLibrary(scalaVersion: String, graph: ModuleGraph): ModuleGraph = { - val scalaLibraryId = ModuleId("org.scala-lang", "scala-library", scalaVersion) + def isScalaLibrary(m: Module) = isScalaLibraryId(m.id) + def isScalaLibraryId(id: ModuleId) = id.organisation == "org.scala-lang" && id.name == "scala-library" def dependsOnScalaLibrary(m: Module): Boolean = - graph.dependencyMap(m.id).map(_.id).contains(scalaLibraryId) + graph.dependencyMap(m.id).exists(isScalaLibrary) def addScalaLibraryAnnotation(m: Module): Module = { if (dependsOnScalaLibrary(m)) @@ -130,8 +131,8 @@ object IvyGraphMLDependencies extends App { m } - val newNodes = graph.nodes.map(addScalaLibraryAnnotation).filterNot(_.id == scalaLibraryId) - val newEdges = graph.edges.filterNot(_._2 == scalaLibraryId) + val newNodes = graph.nodes.map(addScalaLibraryAnnotation).filterNot(isScalaLibrary) + val newEdges = graph.edges.filterNot(e => isScalaLibraryId(e._2)) ModuleGraph(newNodes, newEdges) } From dfdba572483f8896813ac76395091efd9078242d Mon Sep 17 00:00:00 2001 From: Jay Taylor Date: Tue, 26 Aug 2014 20:26:08 -0700 Subject: [PATCH 4/6] Clearer messaging for `sbt 'dependency-graph --force'` command. --- src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala b/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala index 24f6cca6a..4dcb85b68 100755 --- a/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala @@ -106,7 +106,7 @@ object Plugin extends sbt.Plugin { if (!force) { streams.log.info("\n") - streams.log.info("Note: The graph was estimated to be too big to display (> 15 nodes). Use `dependency-graph --force` to force graph display.") + 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.") } } } From b976fa68a529e36619bddfcad5e3683f2a0d4d3f Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Sat, 13 Dec 2014 00:01:24 +0700 Subject: [PATCH 5/6] Describe how to configure the plugin globally Closes #41 --- README.md | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index def8eb3d0..91320112e 100644 --- a/README.md +++ b/README.md @@ -6,37 +6,23 @@ Visualize your project's dependencies. How To Use ---------- -For sbt 0.11/0.12/0.13, add sbt-dependency-graph as a dependency in `project/plugins.sbt`: +Since sbt-dependency-graph is an informational tool rather than one that changes your build, you will more than likely wish to +install it as a [global plugin] so that you can use it in any SBT project without the need to explicitly add it to each one. To do +this, add the plugin dependency to `~/.sbt/0.13/plugins/plugins.sbt`: ```scala addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4") ``` -Then, add the following to your `/build.sbt` (that's not `project/build.sbt`!) as a standalone line: +Then, apply the plugin's settings in `~/.sbt/0.13/global.sbt`, the [global build configuration]: ```scala net.virtualvoid.sbt.graph.Plugin.graphSettings ``` -OR, alternatively, if you use the full configuration, i.e. you define your build definition in `project/build.scala`, for example, -to define a multi-module project, you should add - -```scala -.settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*) -``` - -to each of the project definitions for which you want to use the plugin. The definition of your project should then -look approximately this way: - -```scala -object MyBuild extends Build { - val proj = - Project("my-project", file("base")) - .settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*) -} -``` - -Check out the [example project] for a skeleton build setup. +For both of the above, be sure to use the version directory matching your version of SBT (e.g. 0.12 or 0.13). Be aware that +different projects using SBT may declare particular versions for their builds, so you may need to set up the plugin for an older +version if you encounter a project using one. Tasks ----- @@ -115,4 +101,5 @@ Copyright (c) 2011, 2012 Johannes Rudolph Published under the [Apache License 2.0](http://en.wikipedia.org/wiki/Apache_license). -[example project]: https://gist.github.com/3106492 +[global plugin]: http://www.scala-sbt.org/0.13/tutorial/Using-Plugins.html#Global+plugins +[global build configuration]: http://www.scala-sbt.org/0.13/docs/Global-Settings.html From ca25facd174089cfede01e984305b1f77ad63c90 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 21 Mar 2015 21:17:12 -0400 Subject: [PATCH 6/6] Fixes #67. Adds InlineConfigurationWithExcludes handling --- src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala b/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala index 4dcb85b68..3fcafffa9 100755 --- a/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala @@ -199,9 +199,14 @@ object Plugin extends sbt.Plugin { } } + // This is to support 0.13.8's InlineConfigurationWithExcludes while not forcing 0.13.8 + type HasModule = { + val module: ModuleID + } def crossName(ivyModule: IvySbt#Module) = ivyModule.moduleSettings match { case ic: InlineConfiguration => ic.module.name + case hm: HasModule if hm.getClass.getName == "sbt.InlineConfigurationWithExcludes" => hm.module.name case _ => throw new IllegalStateException("sbt-dependency-graph plugin currently only supports InlineConfiguration of ivy settings (the default in sbt)") }