Port actions/aggregate

This commit is contained in:
Eugene Yokota 2016-03-29 00:03:12 -04:00
parent 4c50dc054a
commit c60578e297
5 changed files with 24 additions and 21 deletions

View File

@ -0,0 +1 @@
lazy val root = (project in file("."))

View File

@ -0,0 +1,7 @@
lazy val root = (project in file(".")).
aggregate((if(file("aggregate").exists) Seq(sub: sbt.ProjectReference) else Nil): _*)
lazy val sub = (project in file("sub")).
aggregate(sub2)
lazy val sub2 = (project in file("sub") / "sub")

View File

@ -3,16 +3,20 @@ import Keys._
import Import._
import Project.Initialize
trait Marker
object Marker extends AutoPlugin
{
final lazy val Mark = TaskKey[Unit]("mark")
final def mark: Initialize[Task[Unit]] = mark(baseDirectory)
final def mark(project: Reference): Initialize[Task[Unit]] = mark(baseDirectory in project)
final def mark(baseKey: SettingKey[File]): Initialize[Task[Unit]] = baseKey map { base =>
val toMark = base / "ran"
if(toMark.exists)
error("Already ran (" + toMark + " exists)")
else
IO touch toMark
}
override def trigger = allRequirements
override def requires = sbt.plugins.JvmPlugin
object autoImport {
final lazy val Mark = TaskKey[Unit]("mark")
final def mark: Initialize[Task[Unit]] = mark(baseDirectory)
final def mark(project: Reference): Initialize[Task[Unit]] = mark(baseDirectory in project)
final def mark(baseKey: SettingKey[File]): Initialize[Task[Unit]] = baseKey map { base =>
val toMark = base / "ran"
if(toMark.exists)
error("Already ran (" + toMark + " exists)")
else
IO touch toMark
}
}
}

View File

@ -1,10 +0,0 @@
import sbt._
import Import._
object SingleBuild extends Build with Marker
{
override def projects = if(file("multi").exists) Seq(root, sub, sub2) else Seq(root)
lazy val root = Project("root", file("."), aggregate = if(file("aggregate").exists) Seq(sub) else Nil )
lazy val sub = Project("sub", file("sub"), aggregate = Seq(sub2))
lazy val sub2 = Project("sub2", file("sub") / "sub")
}

View File

@ -22,6 +22,7 @@ $ delete ran
# switch to multi-project, no aggregation yet. 'reload' will drop session settings
$ touch multi
$ copy-file changes/build.sbt build.sbt
$ mkdir sub sub/sub
> reload