Skip to content

Commit ecbf5a9

Browse files
authored
Use sbt-dependency-graph 0.10.0-RC1 (#19)
without the changes suggested in sbt/sbt-dependency-graph#168
1 parent 2f2b65e commit ecbf5a9

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

build.sbt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ organization := "com.lightbend.paradox"
1414
name := "sbt-paradox-dependencies"
1515

1616
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.4.3")
17-
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2+10-148ba0ff")
18-
19-
resolvers += Resolver.bintrayIvyRepo("2m", "sbt-plugins")
17+
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")
2018

2119
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))
2220
homepage := Some(url("https://github.com/lightbend/sbt-paradox-dependencies"))

src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@
1717
package com.lightbend.paradox.dependencies
1818

1919
import com.lightbend.paradox.markdown.LeafBlockDirective
20-
import net.virtualvoid.sbt.graph.{ModuleTree, ModuleTreeNode}
20+
import net.virtualvoid.sbt.graph.{Module, ModuleGraph}
2121
import org.pegdown.Printer
2222
import org.pegdown.ast.{DirectiveNode, Visitor}
2323

24-
class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: String => ModuleTree)
24+
class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: String => ModuleGraph)
2525
extends LeafBlockDirective("dependencies") {
2626
def render(node: DirectiveNode, visitor: Visitor, printer: Printer): Unit = {
2727
val projectId = node.attributes.value("projectId")
28-
val tree = projectIdToDependencies(projectId)
28+
val graph = projectIdToDependencies(projectId)
2929
printer.println()
3030
val classes = Seq("dependencies", node.attributes.classesString).filter(_.nonEmpty)
3131
printer.print(s"""<dl class="${classes.mkString(" ")}">""")
32-
if (tree.roots.flatMap(_.children).nonEmpty) {
33-
renderDirect(node, tree.roots, showLicenses, printer)
34-
renderTree(node, tree.roots, printer)
32+
if (graph.roots.flatMap(m => children(graph, m)).nonEmpty) {
33+
renderDirect(graph, showLicenses, printer)
34+
renderTree(graph, printer)
3535
} else {
3636
printer.print("<dt>Direct dependencies</dt><dd>This module has no dependencies.</dd>")
3737
}
3838
printer.print("</dl>")
3939
printer.println()
4040
}
4141

42-
private def renderDirect(node: DirectiveNode, roots: Seq[ModuleTreeNode], showLicenses: Boolean, p: Printer): Unit = {
42+
private def renderDirect(graph: ModuleGraph, showLicenses: Boolean, p: Printer): Unit = {
4343
p.print("<dt>Direct dependencies</dt><dd><table>")
4444
p.indent(2).println()
4545
p.print("<thead><tr><th>Organization</th><th>Artifact</th><th>Version</th>")
@@ -48,10 +48,10 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
4848
p.print("<tbody>")
4949
p.indent(2)
5050
for {
51-
r <- roots
52-
d <- r.children
51+
r <- graph.roots
52+
d <- children(graph, r)
5353
} {
54-
val moduleId = d.node.id
54+
val moduleId = d.id
5555
val name = moduleId.name
5656
p.println()
5757
.print("<tr><td>")
@@ -64,7 +64,7 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
6464
)
6565
.print(moduleId.version)
6666
.print("</a></td>")
67-
if (showLicenses) d.node.license.foreach(l => p.print("<td>").print(l).print("</td>"))
67+
if (showLicenses) d.license.foreach(l => p.print("<td>").print(l).print("</td>"))
6868
p.print("</tr>")
6969
}
7070
p.indent(-2).println()
@@ -73,20 +73,20 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
7373
p.print("</table></dd>").println()
7474
}
7575

76-
private def renderTree(node: DirectiveNode, roots: Seq[ModuleTreeNode], p: Printer): Unit = {
76+
private def renderTree(graph: ModuleGraph, p: Printer): Unit = {
7777
p.print("<dt>Dependency tree</dt><dd><pre>")
7878
for {
79-
r <- roots
80-
d <- r.children
79+
r <- graph.roots
80+
d <- children(graph, r)
8181
} {
82-
renderTreeNode(p, d)
82+
renderTreeNode(p, graph, d)
8383
}
8484
p.print("</pre></dd>").println()
8585
}
8686

87-
private def renderTreeNode(p: Printer, n: ModuleTreeNode): Unit =
88-
if (n.node.evictedByVersion.isEmpty) {
89-
val moduleId = n.node.id
87+
private def renderTreeNode(p: Printer, graph: ModuleGraph, n: Module): Unit =
88+
if (n.evictedByVersion.isEmpty) {
89+
val moduleId = n.id
9090
val name = moduleId.name
9191
p.println()
9292
.print(moduleId.organisation)
@@ -97,12 +97,14 @@ class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: Stri
9797
)
9898
.print(moduleId.version)
9999
.print("</a>")
100-
n.node.license.foreach(l => p.print(" ").print(l))
101-
if (n.children.nonEmpty) {
100+
n.license.foreach(l => p.print(" ").print(l))
101+
if (children(graph, n).nonEmpty) {
102102
p.indent(4)
103-
n.children.foreach(renderTreeNode(p, _))
103+
children(graph, n).foreach(renderTreeNode(p, graph, _))
104104
p.indent(-4)
105105
}
106106
}
107107

108+
private def children(graph: ModuleGraph, module: Module) = graph.dependencyMap(module.id)
109+
108110
}

src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package com.lightbend.paradox.dependencies
1919
import com.lightbend.paradox.markdown.Writer
2020
import com.lightbend.paradox.sbt.ParadoxPlugin
2121
import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport.paradoxDirectives
22-
import net.virtualvoid.sbt.graph.{DependencyGraphKeys, ModuleTree}
22+
import net.virtualvoid.sbt.graph.{DependencyGraphKeys, ModuleGraph}
2323
import sbt._
2424
import sbt.Keys._
2525

@@ -47,7 +47,8 @@ object ParadoxDependenciesPlugin extends AutoPlugin {
4747
val filter: ScopeFilter = ScopeFilter(projectsToFilter, inConfigurations(Compile))
4848

4949
val projectIdWithTree = Def.task {
50-
(thisProject.value.id, ModuleTree(DependencyGraphKeys.moduleGraphSbt.value))
50+
val sbtGraph = DependencyGraphKeys.moduleGraphSbt.value
51+
(thisProject.value.id, ModuleGraph.apply(sbtGraph.nodes, sbtGraph.edges))
5152
}
5253

5354
projectIdWithTree.all(filter).map(_.toMap)

src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616

1717
package com.lightbend.paradox.dependencies
1818

19-
import net.virtualvoid.sbt.graph.ModuleTree
20-
19+
import net.virtualvoid.sbt.graph.ModuleGraph
2120
import sbt._
2221

2322
trait ParadoxDependenciesPluginKeys {
2423
val paradoxDependenciesProjects = settingKey[Seq[ProjectReference]]("Projects to get the dependency information for")
2524
val paradoxDependenciesShowLicenses =
2625
settingKey[Boolean]("Show the license column (license information is unavailable with sbt 1.3.2)")
27-
val paradoxDependenciesModuleTrees = taskKey[Map[String, ModuleTree]]("Retrieved module trees")
26+
val paradoxDependenciesModuleTrees = taskKey[Map[String, ModuleGraph]]("Retrieved module graph")
2827
}

0 commit comments

Comments
 (0)