Before I had something like this (simplified), using sbt 0.11.3:
// project/Build.scala
import sbt._
import Keys._
object MyBuild extends Build {
lazy val standardSettings = Defaults.defaultSettings ++ Seq(
version := "0.2",
scalaVersion := "2.9.2"
)
lazy val main = Project(
id = "main",
base = file( "." ),
settings = standardSettings,
aggregate = Seq( sub )
)
lazy val sub = Project(
id = "main-sub",
base = file( "sub" ),
settings = standardSettings
)
}
But I want to keep as much information as possible in the plain build.sbt
file. So now I have
// build.sbt
version := "0.2"
scalaVersion := "2.9.2"
And
// project/Build.scala
import sbt._
import Keys._
object MyBuild extends Build {
lazy val main = Project(
id = "main",
base = file( "." ),
aggregate = Seq( sub )
)
lazy val sub = Project(
id = "main-sub",
base = file( "sub" )
)
}
But that doesn't seem to mix in my settings from build.sbt
into the sub projects:
> show version
[info] main-sub/*:version
[info] 0.1-SNAPSHOT
[info] main/*:version
[info] 0.2
> show scala-version
[info] main-sub/*:scala-version
[info] 2.9.1
[info] main/*:scala-version
[info] 2.9.2
How to remedy this? I also tried to add explicit settings
to the sub-project, e.g.
settings = Defaults.defaultSettings
settings = Project.defaultSettings
settings = MyBuild.settings
settings = main.settings
(sure this one should do?!)...but none worked.
The information is a bit hidden in the last section of sbt's Multi Projects documentation:
When having a single
.scala
file setting up the different projects, it's easy to use reuse settings across different projects. But even when using differentbuild.sbt
files, it's still easy to share settings across all projects from the main build, by using theThisBuild
scope to make a setting apply globally.
Thus:
// build.sbt
version in ThisBuild := "0.2"
scalaVersion in ThisBuild := "2.9.2"
Wow, that sucks big time if you have two dozen keys.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With