As of sbt 0.13, the recommended way to define all configuration is multi-project .sbt build definition. It is absolutely clear how to define settings for each project there; however, how one should define build-wide settings, for example, in ThisBuild
or Global
scopes?
With Scala build definitions it is clear: we have settings
key coming from Build
trait:
object MyBuild extends Build {
override lazy val settings = super.settings ++ Seq(
someKey := someValue
)
}
Now someKey
's value will be build-scoped by default. Alternatively, it can be defined directly in .sbt
file with ThisBuild
scope:
someKey in ThisBuild := someValue
However, there is no natural place to define these options in multi-project .sbt
builds. I suspect that they should be defined in one of the projects with ThisBuild
scope:
val someProject = project
.settings(someKey in ThisBuild := someValue)
but this is very counterintuitive and not really clear: are such settings really applied globally or do they really belong to the specific project? What if I define the same key in multiple projects?
val project1 = project.settings(someKey in ThisBuild := someValue1)
val project2 = project.settings(someKey in ThisBuild := someValue2)
The documentation does not give any answers on this, unfortunately.
Note that I explicitly do not ask how to share global settings between builds or projects. I ask specifically about defining build-scoped settings.
implicit class RichProject(project: Project) { def baseSettings(project: Project) = project.settings(...)}
– Ende Neu