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"""
Organization | Artifact | Version | License |
---|---|---|---|
Organization | Artifact | Version | ") + if (showLicenses) p.print("License | ").print(l).print(" | ")) + if (showLicenses) d.node.license.foreach(l => p.print("").print(l).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") }