From dc9d70200cc332692083a020b1d419f220ac1173 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Thu, 1 Dec 2011 11:39:45 +0100 Subject: [PATCH] rename `ivy-report` to `ivy-report-function` and introduce new InputTask `ivy-report` which results in the location of the ivy report file when given a configuration --- .../scala/net/virtualvoid/sbt/graph/Plugin.scala | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala b/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala index b9d98b940..420262ea8 100644 --- a/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala +++ b/src/main/scala/net/virtualvoid/sbt/graph/Plugin.scala @@ -6,15 +6,25 @@ import Keys._ object Plugin extends sbt.Plugin { val dependencyGraphTask = TaskKey[File]("dependency-graph", "Creates a graphml file containing the dependency-graph for a project") - val ivyReport = SettingKey[String => File]("ivy-report", + val ivyReportF = SettingKey[String => File]("ivy-report-function", "A function which returns the file containing the ivy report from the ivy cache for a given configuration") + val ivyReport = InputKey[File]("ivy-report", + "A task which returns the location of the ivy report file for a given configuration (default `compile`).") def graphSettings = Seq( - ivyReport <<= (projectID, scalaVersion, appConfiguration) { (projectID, scalaVersion, config) => + ivyReportF <<= (projectID, scalaVersion, appConfiguration) { (projectID, scalaVersion, config) => val home = config.provider.scalaProvider.launcher.ivyHome (c: String) => file("%s/cache/%s-%s-%s.xml" format (home, projectID.organization, crossName(projectID, scalaVersion), c)) }, - dependencyGraphTask <<= (ivyReport, target, streams) map { (report, target, streams) => + ivyReport <<= inputTask { args => + (args, ivyReportF) map { (args, report) => + if (args.isEmpty) + report("compile") + else + report(args(0)) + } + }, + dependencyGraphTask <<= (ivyReportF, target, streams) map { (report, target, streams) => val resultFile = target / "dependencies.graphml" IvyGraphMLDependencies.transform(report("compile").getAbsolutePath, resultFile.getAbsolutePath) streams.log.info("Wrote dependency graph to '%s'" format resultFile)