O'Reilly logo

sbt in Action by Josh Suereth and Matthew Farwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. Advanced setting/task API

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.

C.1. Optional settings

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required