diff --git a/build.sbt b/build.sbt
index 5fa081f..a92afcf 100644
--- a/build.sbt
+++ b/build.sbt
@@ -14,9 +14,7 @@ organization := "com.lightbend.paradox"
name := "sbt-paradox-dependencies"
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.4.3")
-addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2+10-148ba0ff")
-
-resolvers += Resolver.bintrayIvyRepo("2m", "sbt-plugins")
+addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))
homepage := Some(url("https://github.com/lightbend/sbt-paradox-dependencies"))
diff --git a/src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala b/src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala
index 9c48853..cf7786a 100644
--- a/src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala
+++ b/src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala
@@ -17,21 +17,21 @@
package com.lightbend.paradox.dependencies
import com.lightbend.paradox.markdown.LeafBlockDirective
-import net.virtualvoid.sbt.graph.{ModuleTree, ModuleTreeNode}
+import net.virtualvoid.sbt.graph.{Module, ModuleGraph}
import org.pegdown.Printer
import org.pegdown.ast.{DirectiveNode, Visitor}
-class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: String => ModuleTree)
+class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: String => ModuleGraph)
extends LeafBlockDirective("dependencies") {
def render(node: DirectiveNode, visitor: Visitor, printer: Printer): Unit = {
val projectId = node.attributes.value("projectId")
- val tree = projectIdToDependencies(projectId)
+ val graph = projectIdToDependencies(projectId)
printer.println()
val classes = Seq("dependencies", node.attributes.classesString).filter(_.nonEmpty)
printer.print(s"""
""")
- if (tree.roots.flatMap(_.children).nonEmpty) {
- renderDirect(node, tree.roots, showLicenses, printer)
- renderTree(node, tree.roots, printer)
+ if (graph.roots.flatMap(m => children(graph, m)).nonEmpty) {
+ renderDirect(graph, showLicenses, printer)
+ renderTree(graph, printer)
} else {
printer.print("- Direct dependencies
- This module has no dependencies.
")
}
@@ -39,7 +39,7 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
printer.println()
}
- private def renderDirect(node: DirectiveNode, roots: Seq[ModuleTreeNode], showLicenses: Boolean, p: Printer): Unit = {
+ private def renderDirect(graph: ModuleGraph, showLicenses: Boolean, p: Printer): Unit = {
p.print("- Direct dependencies
")
p.indent(2).println()
p.print("Organization | Artifact | Version | ")
@@ -48,10 +48,10 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
p.print("
")
p.indent(2)
for {
- r <- roots
- d <- r.children
+ r <- graph.roots
+ d <- children(graph, r)
} {
- val moduleId = d.node.id
+ val moduleId = d.id
val name = moduleId.name
p.println()
.print("")
@@ -64,7 +64,7 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
)
.print(moduleId.version)
.print(" | ")
- if (showLicenses) d.node.license.foreach(l => p.print("").print(l).print(" | "))
+ if (showLicenses) d.license.foreach(l => p.print("").print(l).print(" | "))
p.print("
")
}
p.indent(-2).println()
@@ -73,20 +73,20 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
p.print("
").println()
}
- private def renderTree(node: DirectiveNode, roots: Seq[ModuleTreeNode], p: Printer): Unit = {
+ private def renderTree(graph: ModuleGraph, p: Printer): Unit = {
p.print("- Dependency tree
")
for {
- r <- roots
- d <- r.children
+ r <- graph.roots
+ d <- children(graph, r)
} {
- renderTreeNode(p, d)
+ renderTreeNode(p, graph, d)
}
p.print("
").println()
}
- private def renderTreeNode(p: Printer, n: ModuleTreeNode): Unit =
- if (n.node.evictedByVersion.isEmpty) {
- val moduleId = n.node.id
+ private def renderTreeNode(p: Printer, graph: ModuleGraph, n: Module): Unit =
+ if (n.evictedByVersion.isEmpty) {
+ val moduleId = n.id
val name = moduleId.name
p.println()
.print(moduleId.organisation)
@@ -97,12 +97,14 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
)
.print(moduleId.version)
.print("")
- n.node.license.foreach(l => p.print(" ").print(l))
- if (n.children.nonEmpty) {
+ n.license.foreach(l => p.print(" ").print(l))
+ if (children(graph, n).nonEmpty) {
p.indent(4)
- n.children.foreach(renderTreeNode(p, _))
+ children(graph, n).foreach(renderTreeNode(p, graph, _))
p.indent(-4)
}
}
+ private def children(graph: ModuleGraph, module: Module) = graph.dependencyMap(module.id)
+
}
diff --git a/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala b/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala
index 515c19b..6d237e2 100644
--- a/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala
+++ b/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala
@@ -19,7 +19,7 @@ package com.lightbend.paradox.dependencies
import com.lightbend.paradox.markdown.Writer
import com.lightbend.paradox.sbt.ParadoxPlugin
import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport.paradoxDirectives
-import net.virtualvoid.sbt.graph.{DependencyGraphKeys, ModuleTree}
+import net.virtualvoid.sbt.graph.{DependencyGraphKeys, ModuleGraph}
import sbt._
import sbt.Keys._
@@ -47,7 +47,8 @@ object ParadoxDependenciesPlugin extends AutoPlugin {
val filter: ScopeFilter = ScopeFilter(projectsToFilter, inConfigurations(Compile))
val projectIdWithTree = Def.task {
- (thisProject.value.id, ModuleTree(DependencyGraphKeys.moduleGraphSbt.value))
+ val sbtGraph = DependencyGraphKeys.moduleGraphSbt.value
+ (thisProject.value.id, ModuleGraph.apply(sbtGraph.nodes, sbtGraph.edges))
}
projectIdWithTree.all(filter).map(_.toMap)
diff --git a/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala b/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala
index 39f1783..74346c0 100644
--- a/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala
+++ b/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala
@@ -16,13 +16,12 @@
package com.lightbend.paradox.dependencies
-import net.virtualvoid.sbt.graph.ModuleTree
-
+import net.virtualvoid.sbt.graph.ModuleGraph
import sbt._
trait ParadoxDependenciesPluginKeys {
val paradoxDependenciesProjects = settingKey[Seq[ProjectReference]]("Projects to get the dependency information for")
val paradoxDependenciesShowLicenses =
settingKey[Boolean]("Show the license column (license information is unavailable with sbt 1.3.2)")
- val paradoxDependenciesModuleTrees = taskKey[Map[String, ModuleTree]]("Retrieved module trees")
+ val paradoxDependenciesModuleTrees = taskKey[Map[String, ModuleGraph]]("Retrieved module graph")
}