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

This commit is contained in:
Johannes Rudolph 2011-12-01 11:39:45 +01:00
parent 43c6006f4e
commit dc9d70200c
1 changed files with 13 additions and 3 deletions

View File

@ -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)