mirror of https://github.com/sbt/sbt.git
Intial implementation of CompositeProject
This commit is contained in:
parent
fa56cf394b
commit
cbb953279c
|
|
@ -119,7 +119,13 @@ sealed trait ProjectDefinition[PR <: ProjectReference] {
|
|||
if (ts.isEmpty) Nil else s"$label: $ts" :: Nil
|
||||
}
|
||||
|
||||
sealed trait Project extends ProjectDefinition[ProjectReference] {
|
||||
trait CompositeProject {
|
||||
def componentProjects: Seq[Project]
|
||||
}
|
||||
|
||||
sealed trait Project extends ProjectDefinition[ProjectReference] with CompositeProject {
|
||||
def componentProjects: Seq[Project] = this :: Nil
|
||||
|
||||
private[sbt] def copy(
|
||||
id: String = id,
|
||||
base: File = base,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ import sbt.internal.inc.ReflectUtilities
|
|||
|
||||
trait BuildDef {
|
||||
def projectDefinitions(baseDirectory: File): Seq[Project] = projects
|
||||
def projects: Seq[Project] = ReflectUtilities.allVals[Project](this).values.toSeq
|
||||
def projects: Seq[Project] =
|
||||
ReflectUtilities.allVals[CompositeProject](this).values.toSeq.flatMap(_.componentProjects)
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -123,10 +123,10 @@ private[sbt] object EvaluateConfigurations {
|
|||
// Tracks all the files we generated from evaluating the sbt file.
|
||||
val allGeneratedFiles = (definitions.generated ++ dslEntries.flatMap(_.generated))
|
||||
loader => {
|
||||
val projects =
|
||||
definitions.values(loader).collect {
|
||||
case p: Project => resolveBase(file.getParentFile, p)
|
||||
}
|
||||
val projects = definitions.values(loader).flatMap {
|
||||
case p: CompositeProject => p.componentProjects.map(resolveBase(file.getParentFile, _))
|
||||
case _ => Nil
|
||||
}
|
||||
val (settingsRaw, manipulationsRaw) =
|
||||
dslEntries map (_.result apply loader) partition {
|
||||
case DslEntry.ProjectSettings(_) => true
|
||||
|
|
@ -234,7 +234,7 @@ private[sbt] object EvaluateConfigurations {
|
|||
}
|
||||
|
||||
private[this] def extractedValTypes: Seq[String] =
|
||||
Seq(classOf[Project], classOf[InputKey[_]], classOf[TaskKey[_]], classOf[SettingKey[_]]).map(_.getName)
|
||||
Seq(classOf[CompositeProject], classOf[InputKey[_]], classOf[TaskKey[_]], classOf[SettingKey[_]]).map(_.getName)
|
||||
|
||||
private[this] def evaluateDefinitions(eval: Eval, name: String, imports: Seq[(String, Int)], definitions: Seq[(String, LineRange)], file: Option[File]): compiler.EvalDefinitions =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
object A
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
val aa = taskKey[Unit]("A task in the 'a' project")
|
||||
aa := println("Hello.")
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
val h = taskKey[Unit]("A task in project 'b'")
|
||||
h := println("Hello.")
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import sbt.internal.AddSettings
|
||||
import sbt.CompositeProject
|
||||
|
||||
// Based on sbt-file-projects test
|
||||
val cross = new CompositeProject
|
||||
{
|
||||
val p1 = Project.apply("a", new File("a"))
|
||||
val p2 = Project.apply("b", new File("b"))
|
||||
def componentProjects: Seq[Project] = Seq(p1, p2)
|
||||
}
|
||||
|
||||
val g = taskKey[Unit]("A task in the root project")
|
||||
g := println("Hello.")
|
||||
|
|
@ -0,0 +1 @@
|
|||
lazy val root = (project in file("."))
|
||||
|
|
@ -0,0 +1 @@
|
|||
val c = project
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
> g
|
||||
-> root/compile
|
||||
> a/compile
|
||||
> a/aa
|
||||
> b/compile
|
||||
> b/h
|
||||
> c/compile
|
||||
|
||||
$ copy-file changes/basic.sbt basic.sbt
|
||||
> reload
|
||||
> g
|
||||
> root/compile
|
||||
> a/compile
|
||||
> a/aa
|
||||
> b/compile
|
||||
> b/h
|
||||
> c/compile
|
||||
Loading…
Reference in New Issue