mirror of https://github.com/sbt/sbt.git
Allow root project to be explicitly specified in Build.rootProject
This commit is contained in:
parent
a9289ad0ce
commit
bb1725f580
|
|
@ -14,6 +14,9 @@ trait Build
|
|||
def projects: Seq[Project] = ReflectUtilities.allVals[Project](this).values.toSeq
|
||||
def settings: Seq[Setting[_]] = Defaults.buildCore
|
||||
def buildLoaders: Seq[BuildLoader.Components] = Nil
|
||||
/** Explicitly defines the root project.
|
||||
* If None, the root project is the first project in the build's root directory or just the first project if none are in the root directory.*/
|
||||
def rootProject: Option[Project] = None
|
||||
}
|
||||
trait Plugin
|
||||
{
|
||||
|
|
|
|||
|
|
@ -294,9 +294,10 @@ object Load
|
|||
def isRoot(p: Project) = p.base == unit.localBase
|
||||
|
||||
val externals = referenced(defined).toList
|
||||
val projectsInRoot = defined.filter(isRoot).map(_.id)
|
||||
val rootProjects = if(projectsInRoot.isEmpty) defined.head.id :: Nil else projectsInRoot
|
||||
(new PartBuildUnit(unit, defined.map(d => (d.id, d)).toMap, rootProjects, buildSettings(unit)), externals)
|
||||
val explicitRoots = unit.definitions.builds.flatMap(_.rootProject)
|
||||
val projectsInRoot = if(explicitRoots.isEmpty) defined.filter(isRoot) else explicitRoots
|
||||
val rootProjects = if(projectsInRoot.isEmpty) defined.head :: Nil else projectsInRoot
|
||||
(new PartBuildUnit(unit, defined.map(d => (d.id, d)).toMap, rootProjects.map(_.id), buildSettings(unit)), externals)
|
||||
}
|
||||
def buildSettings(unit: BuildUnit): Seq[Setting[_]] =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object B extends Build
|
||||
{
|
||||
override def rootProject = Some(a)
|
||||
|
||||
lazy val a = Project("a", file("a")) settings(
|
||||
TaskKey[Unit]("taskA") := {}
|
||||
)
|
||||
lazy val b = Project("b", file("b")) settings(
|
||||
TaskKey[Unit]("taskB") := {}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object B extends Build
|
||||
{
|
||||
override def rootProject = Some(d)
|
||||
|
||||
lazy val c = Project("c", file("c")) settings(
|
||||
TaskKey[Unit]("taskC") := {}
|
||||
)
|
||||
lazy val d = Project("d", file("d")) settings(
|
||||
TaskKey[Unit]("taskD") := {}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
$ copy-file changes/RootA.scala project/P.scala
|
||||
> reload
|
||||
> taskA
|
||||
-> taskB
|
||||
> b/taskB
|
||||
|
||||
$ copy-file changes/RootD.scala project/P.scala
|
||||
> reload
|
||||
> taskD
|
||||
-> taskC
|
||||
> c/taskC
|
||||
Loading…
Reference in New Issue