I have a simple multi project, whereby the root aggregates projects a
and b
. The root project loads this plugin I'm writing that is supposed to allow easy integration with the build system in our company.
lazy val a = project in file("a")
lazy val b = project in file("b")
Now, I'd like to define some Setting
s in the plugin that don't make sense in the root project, and can have different values for each sub-project. However, if I just define them like
object P extends Plugin {
val kind = settingKey[Kind]("App or Lib?")
val ourResolver = settingKey[Resolver]("...")
override def projectSettings = Seq(
// I want this to only be defined in a and b, where `kind` is defined
ourResolver <<= kind { k => new OurInternalResolver(k) }
)
}
then sbt will complain that ourResolver
cannot be defined because kind
is not defined in the root project.
Is there a way to specify a scope for this setting (ourResolver
), such that the setting would be defined in every aggregated project except the root project?
Or do I have to make it into an SettingKey[Option[_]]
and set it to None
by default?
Edit: I have quite a large set of settings which progressively depend on kind
and then ourResolver
and so on, and these settings should only be defined where (read: "in the project scopes where") kind
is defined. Added ourResolver
to example code to reflect this.