Merge commit 'pull/68'

This commit is contained in:
Johannes Rudolph 2015-03-29 11:59:17 +02:00
commit b6400fc573
3 changed files with 43 additions and 37 deletions

View File

@ -6,40 +6,26 @@ 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`:
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 `<project-root>/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
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.
```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.
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-<config>.graphml`.
@ -50,14 +36,6 @@ Tasks & Settings
* `what-depends-on <organization> <module> <revision>`: 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]<BR/><B>[name]</B><BR/>[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 +43,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]<BR/><B>[name]</B><BR/>[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
----------------
@ -102,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

View File

@ -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)
}

View File

@ -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.")
}
}
}
@ -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)")
}