Make val loading order top-to-bottom

Fixes #2232

Within `build.sbt` this makes sure that definitions are ordered from top to bottom.
This matters when multiple subprojects refer to the same setting (probably not a good practice).
This commit is contained in:
Eugene Yokota 2020-02-22 04:45:34 -05:00
parent 523795e204
commit b97de940a5
3 changed files with 39 additions and 2 deletions

View File

@ -161,8 +161,8 @@ final class Eval(
case None => ""
}
}
val i = evalCommon(definitions.map(_._1), imports, Some(""), ev)
new EvalDefinitions(i.loader, i.generated, i.enclosingModule, i.extra)
val i: EvalIntermediate[Seq[String]] = evalCommon(definitions.map(_._1), imports, Some(""), ev)
new EvalDefinitions(i.loader, i.generated, i.enclosingModule, i.extra.reverse)
}
private[this] def evalCommon[T](

View File

@ -0,0 +1,36 @@
ThisBuild / scalaVersion := "2.13.1"
ThisBuild / version := "0.1.0-SNAPSHOT"
lazy val check = taskKey[Unit]("")
lazy val intTask = taskKey[Int]("int task")
lazy val root = (project in file("."))
.settings(
name := "val-ordering-test",
ThisBuild / organization := "root",
check := {
val o = (ThisBuild / organization).value
assert(o == "root.api.database.web", s"$o")
val x = (api / intTask).value
assert(x == 1, x.toString)
},
)
lazy val api = project
.settings(
intTask := 0,
ThisBuild / organization := (ThisBuild / organization).value + ".api",
)
lazy val database = project
.settings(
ThisBuild / organization := (ThisBuild / organization).value + ".database",
)
lazy val web = project
.dependsOn(api, database)
.settings(
api / intTask := 1,
ThisBuild / organization := (ThisBuild / organization).value + ".web",
)

View File

@ -0,0 +1 @@
> check