mirror of https://github.com/sbt/sbt.git
a bunch of refactorings and setting renamings
This commit is contained in:
parent
9f4852ac64
commit
a7e37c4ac0
|
|
@ -20,31 +20,31 @@ import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
|
|
||||||
object Plugin extends sbt.Plugin {
|
object Plugin extends sbt.Plugin {
|
||||||
val dependencyGraphTask = TaskKey[File]("dependency-graph",
|
val dependencyGraphML = TaskKey[File]("dependency-graph-ml",
|
||||||
"Creates a graphml file containing the dependency-graph for a project")
|
"Creates a graphml file containing the dependency-graph for a project")
|
||||||
val asciiGraph = TaskKey[String]("ascii-graph",
|
val asciiGraph = TaskKey[String]("dependency-graph-string",
|
||||||
"Returns a string containing the ascii representation of the dependency graph for a project")
|
"Returns a string containing the ascii representation of the dependency graph for a project")
|
||||||
val printAsciiGraph = TaskKey[Unit]("print-ascii-graph",
|
val dependencyGraph = TaskKey[Unit]("dependency-graph",
|
||||||
"Prints the ascii graph to the console")
|
"Prints the ascii graph to the console")
|
||||||
val ivyReportF = TaskKey[String => File]("ivy-report-function",
|
val ivyReportFunction = TaskKey[String => File]("ivy-report-function",
|
||||||
"A function which returns the file containing the ivy report from the ivy cache for a given configuration")
|
"A function which returns the file containing the ivy report from the ivy cache for a given configuration")
|
||||||
val ivyReport = InputKey[File]("ivy-report",
|
val ivyReport = InputKey[File]("ivy-report",
|
||||||
"A task which returns the location of the ivy report file for a given configuration (default `compile`).")
|
"A task which returns the location of the ivy report file for a given configuration (default `compile`).")
|
||||||
|
|
||||||
def graphSettings = Seq(
|
def graphSettings = Seq(
|
||||||
ivyReportF <<= (projectID, ivyModule, appConfiguration) map { (projectID, ivyModule, config) =>
|
ivyReportFunction <<= (projectID, ivyModule, appConfiguration) map { (projectID, ivyModule, config) =>
|
||||||
val home = config.provider.scalaProvider.launcher.ivyHome
|
val home = config.provider.scalaProvider.launcher.ivyHome
|
||||||
(c: String) => file("%s/cache/%s-%s-%s.xml" format (home, projectID.organization, crossName(ivyModule), c))
|
(c: String) => file("%s/cache/%s-%s-%s.xml" format (home, projectID.organization, crossName(ivyModule), c))
|
||||||
},
|
},
|
||||||
ivyReport <<= inputTask { args =>
|
ivyReport <<= inputTask { args =>
|
||||||
(args, ivyReportF) map { (args, report) =>
|
(args, ivyReportFunction) map { (args, report) =>
|
||||||
if (args.isEmpty)
|
if (args.isEmpty)
|
||||||
report("compile")
|
report("compile")
|
||||||
else
|
else
|
||||||
report(args(0))
|
report(args(0))
|
||||||
} dependsOn(update)
|
} dependsOn(update)
|
||||||
},
|
},
|
||||||
dependencyGraphTask <<= (ivyReportF, target, streams) map { (report, target, streams) =>
|
dependencyGraphML <<= (ivyReportFunction, target, streams) map { (report, target, streams) =>
|
||||||
val resultFile = target / "dependencies.graphml"
|
val resultFile = target / "dependencies.graphml"
|
||||||
IvyGraphMLDependencies.transform(report("compile").getAbsolutePath, resultFile.getAbsolutePath)
|
IvyGraphMLDependencies.transform(report("compile").getAbsolutePath, resultFile.getAbsolutePath)
|
||||||
streams.log.info("Wrote dependency graph to '%s'" format resultFile)
|
streams.log.info("Wrote dependency graph to '%s'" format resultFile)
|
||||||
|
|
@ -55,17 +55,14 @@ object Plugin extends sbt.Plugin {
|
||||||
def asciiGraphSettings(config: Configuration) =
|
def asciiGraphSettings(config: Configuration) =
|
||||||
seq(
|
seq(
|
||||||
asciiGraph in config <<= asciiGraphTask(config),
|
asciiGraph in config <<= asciiGraphTask(config),
|
||||||
printAsciiGraph in config <<= printAsciiGraphTask(config)
|
dependencyGraph in config <<= printAsciiGraphTask(config)
|
||||||
)
|
)
|
||||||
|
|
||||||
def asciiGraphTask(conf: Configuration) = (ivyReportF in conf) map { (report) =>
|
def asciiGraphTask(conf: Configuration) = (ivyReportFunction in conf) map { (report) =>
|
||||||
IvyGraphMLDependencies.ascii(report(conf.name).getAbsolutePath)
|
IvyGraphMLDependencies.ascii(report(conf.name).getAbsolutePath)
|
||||||
} dependsOn(deliverLocal)
|
} dependsOn(deliverLocal)
|
||||||
|
|
||||||
def printAsciiGraphTask(conf: Configuration) = (asciiGraph in conf, streams in conf) map { (graph, streams) =>
|
def printAsciiGraphTask(conf: Configuration) = (streams in conf, asciiGraph in conf) map (_.log.info(_))
|
||||||
streams.log.info(graph)
|
|
||||||
}
|
|
||||||
|
|
||||||
def crossName(ivyModule: IvySbt#Module) =
|
def crossName(ivyModule: IvySbt#Module) =
|
||||||
ivyModule.moduleSettings match {
|
ivyModule.moduleSettings match {
|
||||||
case ic: InlineConfiguration => ic.module.name
|
case ic: InlineConfiguration => ic.module.name
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue