diff --git a/src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala b/src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala index 9d9983c..9c48853 100644 --- a/src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala +++ b/src/main/scala/com/lightbend/paradox/dependencies/DependenciesDirective.scala @@ -21,7 +21,8 @@ import net.virtualvoid.sbt.graph.{ModuleTree, ModuleTreeNode} import org.pegdown.Printer import org.pegdown.ast.{DirectiveNode, Visitor} -class DependenciesDirective(projectIdToDependencies: String => ModuleTree) extends LeafBlockDirective("dependencies") { +class DependenciesDirective(showLicenses: Boolean)(projectIdToDependencies: String => ModuleTree) + extends LeafBlockDirective("dependencies") { def render(node: DirectiveNode, visitor: Visitor, printer: Printer): Unit = { val projectId = node.attributes.value("projectId") val tree = projectIdToDependencies(projectId) @@ -29,7 +30,7 @@ class DependenciesDirective(projectIdToDependencies: String => ModuleTree) exten val classes = Seq("dependencies", node.attributes.classesString).filter(_.nonEmpty) printer.print(s"""
""") if (tree.roots.flatMap(_.children).nonEmpty) { - renderDirect(node, tree.roots, printer) + renderDirect(node, tree.roots, showLicenses, printer) renderTree(node, tree.roots, printer) } else { printer.print("
Direct dependencies
This module has no dependencies.
") @@ -38,10 +39,12 @@ class DependenciesDirective(projectIdToDependencies: String => ModuleTree) exten printer.println() } - private def renderDirect(node: DirectiveNode, roots: Seq[ModuleTreeNode], p: Printer): Unit = { + private def renderDirect(node: DirectiveNode, roots: Seq[ModuleTreeNode], showLicenses: Boolean, p: Printer): Unit = { p.print("
Direct dependencies
") p.indent(2).println() - p.print("").println() + p.print("") + if (showLicenses) p.print("") + p.print("").println() p.print("") p.indent(2) for { @@ -61,7 +64,7 @@ class DependenciesDirective(projectIdToDependencies: String => ModuleTree) exten ) .print(moduleId.version) .print("") - d.node.license.foreach(l => p.print("")) + if (showLicenses) d.node.license.foreach(l => p.print("")) p.print("") } p.indent(-2).println() diff --git a/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala b/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala index 33d92c8..515c19b 100644 --- a/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala +++ b/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPlugin.scala @@ -34,6 +34,9 @@ object ParadoxDependenciesPlugin extends AutoPlugin { override def projectSettings: Seq[Setting[_]] = dependenciesSettings(Compile) def dependenciesZeroSettings: Seq[Setting[_]] = Seq( + paradoxDependenciesShowLicenses := { + sbtVersion.value.startsWith("1.1.") || sbtVersion.value.startsWith("1.2.") + }, paradoxDependenciesModuleTrees := Def.taskDyn { val projectsToFilter = paradoxDependenciesProjects.?.value .map(inProjects) @@ -54,7 +57,7 @@ object ParadoxDependenciesPlugin extends AutoPlugin { val trees = paradoxDependenciesModuleTrees.value Seq( { _: Writer.Context ⇒ - new DependenciesDirective(projectId => { + new DependenciesDirective(paradoxDependenciesShowLicenses.value)(projectId => { trees.get(projectId) match { case Some(deps) => deps case _ => throw new Error(s"Could not retrieve dependency information for project [$projectId]") diff --git a/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala b/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala index 1bd145a..39f1783 100644 --- a/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala +++ b/src/main/scala/com/lightbend/paradox/dependencies/ParadoxDependenciesPluginKeys.scala @@ -21,6 +21,8 @@ import net.virtualvoid.sbt.graph.ModuleTree import sbt._ trait ParadoxDependenciesPluginKeys { - val paradoxDependenciesProjects = settingKey[Seq[ProjectReference]]("Projects to get the dependency information for") + 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") }
OrganizationArtifactVersionLicense
OrganizationArtifactVersionLicense
").print(l).print("").print(l).print("