mirror of https://github.com/sbt/sbt.git
discover projects reflectively, provide access to build root
This commit is contained in:
parent
8c659328e9
commit
04280a89a4
|
|
@ -16,7 +16,8 @@ package sbt
|
|||
// name is more like BuildDefinition, but that is too long
|
||||
trait Build
|
||||
{
|
||||
def projects: Seq[Project]
|
||||
def projectDefinitions(baseDirectory: File): Seq[Project] = projects
|
||||
def projects: Seq[Project] = ReflectUtilities.allVals[Project](this).values.toSeq
|
||||
def settings: Seq[Setting[_]] = Defaults.buildCore
|
||||
def buildResolvers: Seq[BuildLoader.BuildResolver] = Nil
|
||||
}
|
||||
|
|
@ -27,8 +28,7 @@ trait Plugin
|
|||
|
||||
object Build
|
||||
{
|
||||
def default(base: File): Build = new Build { def projects = defaultProject("default", base) :: Nil }
|
||||
def defaultProject(id: String, base: File): Project = Project(id, base)
|
||||
val default: Build = new Build { override def projectDefinitions(base: File) = Project("default", base) :: Nil }
|
||||
|
||||
def data[T](in: Seq[Attributed[T]]): Seq[T] = in.map(_.data)
|
||||
def analyzed(in: Seq[Attributed[_]]): Seq[inc.Analysis] = in.flatMap{ _.metadata.get(Keys.analysis) }
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ object Load
|
|||
// Therefore, we use resolveProjectBuild instead of resolveProjectRef. After all builds are loaded, we can fully resolve ProjectReferences.
|
||||
val resolveBuild = (_: Project).resolveBuild(ref => Scope.resolveProjectBuild(unit.uri, ref))
|
||||
val resolve = resolveBuild compose resolveBase(unit.localBase)
|
||||
unit.definitions.builds.flatMap(_.projects map resolve)
|
||||
unit.definitions.builds.flatMap(_.projectDefinitions(unit.localBase) map resolve)
|
||||
}
|
||||
def getRootProject(map: Map[URI, BuildUnitBase]): URI => String =
|
||||
uri => getBuild(map, uri).rootProjects.headOption getOrElse emptyBuild(uri)
|
||||
|
|
@ -322,7 +322,7 @@ object Load
|
|||
IO.createDirectory(target)
|
||||
val loadedDefs =
|
||||
if(defs.isEmpty)
|
||||
new LoadedDefinitions(defDir, target, plugs.loader, Build.default(normBase) :: Nil, Nil)
|
||||
new LoadedDefinitions(defDir, target, plugs.loader, Build.default :: Nil, Nil)
|
||||
else
|
||||
definitions(defDir, target, defs, plugs, config.compilers, config.log, normBase)
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ object Load
|
|||
val target = inputs.config.classesDirectory
|
||||
val definitionLoader = ClasspathUtilities.toLoader(target :: Nil, plugins.loader)
|
||||
val defNames = findDefinitions(defAnalysis)
|
||||
val defs = if(defNames.isEmpty) Build.default(buildBase) :: Nil else loadDefinitions(definitionLoader, defNames)
|
||||
val defs = if(defNames.isEmpty) Build.default :: Nil else loadDefinitions(definitionLoader, defNames)
|
||||
new LoadedDefinitions(base, target, definitionLoader, defs, defNames)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue