Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (27 sloc) 1.43 KB
package sbt
import Types.idFun
import BuildDependencies._
final class BuildDependencies private(val classpath: DependencyMap[ClasspathDep[ProjectRef]], val aggregate: DependencyMap[ProjectRef])
def classpathRefs(ref: ProjectRef): Seq[ProjectRef] = classpath(ref) map getID
def classpathTransitiveRefs(ref: ProjectRef): Seq[ProjectRef] = classpathTransitive(ref)
lazy val classpathTransitive: DependencyMap[ProjectRef] = transitive(classpath, getID)
lazy val aggregateTransitive: DependencyMap[ProjectRef] = transitive(aggregate, idFun[ProjectRef])
def addClasspath(ref: ProjectRef, deps: ClasspathDep[ProjectRef]*): BuildDependencies =
new BuildDependencies( classpath.updated(ref, deps ++ classpath.getOrElse(ref, Nil)), aggregate)
def addAggregate(ref: ProjectRef, deps: ProjectRef*): BuildDependencies =
new BuildDependencies(classpath, aggregate.updated(ref, deps ++ aggregate.getOrElse(ref, Nil)))
object BuildDependencies
def apply(classpath: DependencyMap[ClasspathDep[ProjectRef]], aggregate: DependencyMap[ProjectRef]): BuildDependencies =
new BuildDependencies(classpath, aggregate)
type DependencyMap[D] = Map[ProjectRef, Seq[D]]
def transitive[D](deps: DependencyMap[D], extract: D => ProjectRef): DependencyMap[ProjectRef] =
for( (ref, _) <- deps ) yield
val sorted = Dag.topologicalSort(ref)(d => deps(d) map extract)
(ref, sorted dropRight 1)
val getID: ClasspathDep[ProjectRef] => ProjectRef = _.project
Jump to Line
Something went wrong with that request. Please try again.