mirror of https://github.com/sbt/sbt.git
replace unordered collections in several locations with ordered ones
This commit is contained in:
parent
16ad0419a8
commit
37904a1644
|
|
@ -112,7 +112,7 @@ trait DefaultClasspathProject extends BasicClasspathProject with Project
|
|||
new InlineIvyConfiguration(paths, rs, otherResolvers, moduleConfigurations, offline, Some(info.globalLock), ConsoleLogger())
|
||||
}
|
||||
|
||||
def libraryDependencies: Iterable[ModuleID] = ReflectUtilities.allVals[ModuleID](this).map(_._2)
|
||||
def libraryDependencies: Seq[ModuleID] = ReflectUtilities.allVals[ModuleID](this).toSeq.map(_._2)
|
||||
|
||||
def managedDependencyPath: Path = info.projectDirectory / "lib_managed"
|
||||
def dependencyPath: Path = info.projectDirectory / "lib"
|
||||
|
|
@ -132,12 +132,12 @@ trait DefaultClasspathProject extends BasicClasspathProject with Project
|
|||
}
|
||||
trait MultiClasspathProject extends DefaultClasspathProject
|
||||
{
|
||||
def dependencies: Iterable[ProjectDependency.Classpath]
|
||||
def dependencies: Seq[ProjectDependency.Classpath]
|
||||
def name: String
|
||||
def organization: String
|
||||
def version: String
|
||||
|
||||
def projectDependencies: Iterable[ModuleID] =
|
||||
def projectDependencies: Seq[ModuleID] =
|
||||
resolvedDependencies(this) collect { case (p: DefaultClasspathProject, conf) => p.projectID.copy(configurations = conf) }
|
||||
|
||||
lazy val projectResolver =
|
||||
|
|
@ -146,7 +146,7 @@ trait MultiClasspathProject extends DefaultClasspathProject
|
|||
}
|
||||
|
||||
override def projectID = ModuleID(organization, name, version)
|
||||
override def libraryDependencies: Iterable[ModuleID] = super.libraryDependencies ++ projectDependencies
|
||||
override def libraryDependencies: Seq[ModuleID] = super.libraryDependencies ++ projectDependencies
|
||||
|
||||
override lazy val resolvers: Task[Seq[Resolver]] = projectResolver map { _ +: baseResolvers }
|
||||
}
|
||||
|
|
@ -206,7 +206,7 @@ object ClasspathProject
|
|||
}).toMap
|
||||
}
|
||||
|
||||
def resolvedDependencies(p: Project): Iterable[(Project, Option[String])] =
|
||||
def resolvedDependencies(p: Project): Seq[(Project, Option[String])] =
|
||||
p.dependencies map { cp =>
|
||||
(resolveProject(cp.project, p), cp.configuration)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ object MultiProject
|
|||
Build.binaries(inputs.config.classpath, toLoad, getClass.getClassLoader)(construct(info)).head.asInstanceOf[Project]
|
||||
}
|
||||
|
||||
def loadExternals(from: Iterable[Project], loadImpl: File => Project): Map[File, Project] =
|
||||
def loadExternals(from: Seq[Project], loadImpl: File => Project): Map[File, Project] =
|
||||
{
|
||||
def load(loaded: Map[File, Project], file: File): Map[File, Project] =
|
||||
(loaded get file) match
|
||||
|
|
@ -84,9 +84,9 @@ object MultiProject
|
|||
loadAll( externals(from) , Map.empty)
|
||||
}
|
||||
|
||||
def externals(containers: Iterable[Project]): Set[File] =
|
||||
def externals(containers: Seq[Project]): Set[File] =
|
||||
{
|
||||
def exts(containers: Iterable[Project]): Iterable[File] =
|
||||
def exts(containers: Seq[Project]): Seq[File] =
|
||||
containers flatMap { container => externalProjects(container) ++ exts(internalProjects(container)) }
|
||||
exts(containers).toSet
|
||||
}
|
||||
|
|
@ -108,13 +108,13 @@ object MultiProject
|
|||
{
|
||||
val contexts = topologicalSort(root) map { p => (p, ReflectiveContext(p, p.name)) }
|
||||
val externals = root.info.externals
|
||||
def subs(f: Project => Iterable[ProjectDependency]): Project => Iterable[Project] = p =>
|
||||
def subs(f: Project => Seq[ProjectDependency]): Project => Seq[Project] = p =>
|
||||
f(p) map( _.project match { case Left(path) => externals(path); case Right(proj) => proj } )
|
||||
MultiContext(contexts)(subs(_.aggregate), subs(_.dependencies) )
|
||||
}
|
||||
|
||||
def lefts[A,B](e: Iterable[Either[A,B]]):Iterable[A] = e collect { case Left(l) => l }
|
||||
def rights[A,B](e: Iterable[Either[A,B]]):Iterable[B] = e collect { case Right(r)=> r }
|
||||
def lefts[A,B](e: Seq[Either[A,B]]):Seq[A] = e collect { case Left(l) => l }
|
||||
def rights[A,B](e: Seq[Either[A,B]]):Seq[B] = e collect { case Right(r)=> r }
|
||||
|
||||
def transformName(s: String) =
|
||||
{
|
||||
|
|
@ -172,8 +172,8 @@ trait Project extends Tasked with HistoryEnabled with Member[Project] with Named
|
|||
def input = Dummy.In
|
||||
def state = Dummy.State
|
||||
|
||||
def aggregate: Iterable[ProjectDependency.Execution] = info.dependencies collect { case ex: ProjectDependency.Execution => ex }
|
||||
def dependencies: Iterable[ProjectDependency.Classpath] = info.dependencies collect { case cp: ProjectDependency.Classpath => cp }
|
||||
def aggregate: Seq[ProjectDependency.Execution] = info.dependencies collect { case ex: ProjectDependency.Execution => ex }
|
||||
def dependencies: Seq[ProjectDependency.Classpath] = info.dependencies collect { case cp: ProjectDependency.Classpath => cp }
|
||||
|
||||
type Task[T] = sbt.Task[T]
|
||||
def act(input: Input, state: State): Option[(Task[State], Execute.NodeView[Task])] =
|
||||
|
|
@ -202,9 +202,9 @@ trait ProjectExtra
|
|||
}
|
||||
trait ReflectiveProject extends Project
|
||||
{
|
||||
private[this] def vals[T: Manifest] = ReflectUtilities.allVals[T](this).map(_._2)
|
||||
override def aggregate: Iterable[ProjectDependency.Execution] = vals[ProjectDependency.Execution] ++ vals[Project].map(p => ProjectDependency.Execution(Right(p))) ++ super.aggregate
|
||||
override def dependencies: Iterable[ProjectDependency.Classpath] = vals[ProjectDependency.Classpath] ++ super.dependencies
|
||||
private[this] def vals[T: Manifest] = ReflectUtilities.allVals[T](this).toSeq.map(_._2)
|
||||
override def aggregate: Seq[ProjectDependency.Execution] = vals[ProjectDependency.Execution] ++ vals[Project].map(p => ProjectDependency.Execution(Right(p))) ++ super.aggregate
|
||||
override def dependencies: Seq[ProjectDependency.Classpath] = vals[ProjectDependency.Classpath] ++ super.dependencies
|
||||
}
|
||||
trait ConsoleTask
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import inc.Analysis
|
|||
* `parent` is the parent Project, or None if this is the root project.
|
||||
* `buildScalaVersion` contains the explicitly requested Scala version to use for building (as when using `+` or `++`) or None if the normal version should be used.
|
||||
*/
|
||||
final case class ProjectInfo(name: Option[String], projectDirectory: File, builderDir: File, dependencies: Iterable[ProjectDependency], parent: Option[Project])(
|
||||
final case class ProjectInfo(name: Option[String], projectDirectory: File, builderDir: File, dependencies: Seq[ProjectDependency], parent: Option[Project])(
|
||||
val configuration: AppConfiguration, val analysis: Analysis, val compileInputs: Compile.Inputs, val construct: File => Project, external: ExternalProjects)
|
||||
{
|
||||
def app = configuration.provider
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package sbt
|
|||
import std._
|
||||
import Path._
|
||||
import TaskExtra._
|
||||
import scala.collection.{mutable, JavaConversions}
|
||||
import scala.collection.{immutable, mutable, JavaConversions}
|
||||
|
||||
import java.io.File
|
||||
|
||||
|
|
@ -49,15 +49,15 @@ object ReflectiveContext
|
|||
import Transform.Context
|
||||
def apply[Owner <: AnyRef : Manifest](context: Owner, name: String): Context[Owner] = new Context[Owner]
|
||||
{
|
||||
private[sbt] lazy val tasks: Map[String, Task[_]] = ReflectUtilities.allVals[Task[_]](context).toMap
|
||||
private[sbt] lazy val tasks: immutable.SortedMap[String, Task[_]] = ReflectUtilities.allVals[Task[_]](context)
|
||||
private[sbt] lazy val reverseName: collection.Map[Task[_], String] = reverseMap(tasks)
|
||||
private[sbt] lazy val sub: collection.Map[String, Owner] = ReflectUtilities.allVals[Owner](context)
|
||||
private[sbt] lazy val sub: Map[String, Owner] = ReflectUtilities.allVals[Owner](context)
|
||||
private[sbt] lazy val reverseSub: collection.Map[Owner, String] = reverseMap(sub)
|
||||
|
||||
val staticName: Task[_] => Option[String] = reverseName.get _
|
||||
val ownerName = (o: Owner) => if(o eq context) Some(name) else None
|
||||
val owner = (t: Task[_]) => if(reverseName contains t) Some(context) else None
|
||||
def allTasks(o: Owner): Iterable[Task[_]] = if(o eq context) tasks.values else Nil
|
||||
def allTasks(o: Owner): Seq[Task[_]] = if(o eq context) tasks.values.toSeq else Nil
|
||||
def ownerForName(oname: String): Option[Owner] = if(name == oname) Some(context) else None
|
||||
val aggregate = (_: Owner) => Nil
|
||||
val static = (o: Owner, s: String) => if(o eq context) tasks.get(s) else None
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ object ReflectUtilities
|
|||
flatMap(_.getDeclaredFields).
|
||||
map(f => (f.getName, f)):_*)
|
||||
|
||||
def allValsC[T](self: AnyRef, clazz: Class[T]): Map[String, T] =
|
||||
def allValsC[T](self: AnyRef, clazz: Class[T]): immutable.SortedMap[String, T] =
|
||||
{
|
||||
val mappings = new mutable.OpenHashMap[String, T]
|
||||
var mappings = new immutable.TreeMap[String, T]
|
||||
val correspondingFields = fields(self.getClass)
|
||||
for(method <- self.getClass.getMethods)
|
||||
{
|
||||
|
|
@ -45,13 +45,13 @@ object ReflectUtilities
|
|||
{
|
||||
val value = method.invoke(self).asInstanceOf[T]
|
||||
if(value == null) throw new UninitializedVal(method.getName, method.getDeclaringClass.getName)
|
||||
mappings(method.getName) = value
|
||||
mappings += ((method.getName, value))
|
||||
}
|
||||
}
|
||||
}
|
||||
mappings
|
||||
}
|
||||
def allVals[T](self: AnyRef)(implicit mt: scala.reflect.Manifest[T]): Map[String, T] =
|
||||
allValsC(self, mt.erasure).asInstanceOf[Map[String,T]]
|
||||
def allVals[T](self: AnyRef)(implicit mt: scala.reflect.Manifest[T]): immutable.SortedMap[String, T] =
|
||||
allValsC(self, mt.erasure).asInstanceOf[immutable.SortedMap[String,T]]
|
||||
}
|
||||
final class UninitializedVal(val valName: String, val className: String) extends RuntimeException("val " + valName + " in class " + className + " was null.\nThis is probably an initialization problem and a 'lazy val' should be used.")
|
||||
Loading…
Reference in New Issue