Remove projects parameter from CompositeProject.expand

This commit is contained in:
Alistair Johnson 2018-04-07 15:56:31 +02:00
parent 6cce4f6fd9
commit b0ad1a44c0
3 changed files with 11 additions and 21 deletions

View File

@ -128,10 +128,10 @@ trait CompositeProject {
private[sbt] object CompositeProject {
/**
* Expand user defined `projects` with the component projects of `compositeProjects`.
* Expand user defined projects with the component projects of `compositeProjects`.
*
* If two projects with the same id appear in the user defined `projects` and
* in `compositeProjects.componentProjects`, the one in `projects` wins.
* If two projects with the same id appear in the user defined projects and
* in `compositeProjects.componentProjects`, the user defined project wins.
* This is necessary for backward compatibility with the idioms:
* {{{
* lazy val foo = crossProject
@ -145,11 +145,12 @@ private[sbt] object CompositeProject {
* lazy val fooJVM = foo.jvm.settings(...)
* }}}
*/
def expand(projects: Seq[Project], compositeProjects: Seq[CompositeProject]): Seq[Project] = {
def expand(compositeProjects: Seq[CompositeProject]): Seq[Project] = {
val userProjects = compositeProjects.collect { case p: Project => p }
for (p <- compositeProjects.flatMap(_.componentProjects)) yield {
projects.find(_.id == p.id) match {
case Some(overridingProject) => overridingProject
case None => p
userProjects.find(_.id == p.id) match {
case Some(userProject) => userProject
case None => p
}
}
}.distinct

View File

@ -17,11 +17,8 @@ import sbt.internal.inc.ReflectUtilities
trait BuildDef {
def projectDefinitions(@deprecated("unused", "") baseDirectory: File): Seq[Project] = projects
def projects: Seq[Project] = {
val projects = ReflectUtilities.allVals[Project](this).values.toSeq
val compositeProjects = ReflectUtilities.allVals[CompositeProject](this).values.toSeq
CompositeProject.expand(projects, compositeProjects)
}
def projects: Seq[Project] =
CompositeProject.expand(ReflectUtilities.allVals[CompositeProject](this).values.toSeq)
// TODO: Should we grab the build core settings here or in a plugin?
def settings: Seq[Setting[_]] = Defaults.buildCore
def buildLoaders: Seq[BuildLoader.Components] = Nil

View File

@ -152,18 +152,10 @@ private[sbt] object EvaluateConfigurations {
loader =>
{
val projects = {
val projects = definitions.values(loader).collect {
case p: Project => p
}
val compositeProjects = definitions.values(loader).collect {
case p: CompositeProject => p
}
CompositeProject
.expand(projects, compositeProjects)
.map(resolveBase(file.getParentFile, _))
CompositeProject.expand(compositeProjects).map(resolveBase(file.getParentFile, _))
}
val (settingsRaw, manipulationsRaw) =
dslEntries map (_.result apply loader) partition {