Although this book covers the core of sbt, one thing we didn’t get to touch on as much as we desired was the advanced features of the task/setting system. These features aren’t widely used, but they still come in handy when needed. Here we’ll lay out a few use cases and how to achieve them in sbt.
It’s possible to define a SettingKey[Option[String]] to represent a setting that may not be set, but sometimes the user may experience having to write this:
optionalSetting := Some("value")
Instead, sbt provides a mechanism to find out if a particular key has a value. If you want to allow the optionalSetting key to not exist in your build, you can use the ? method to assess its value: ...