Skip to content

Should we recommend the use of inThisBuild(...) in the Getting Started guide? #307

@eed3si9n

Description

@eed3si9n

#306 (comment) Li Haoyi wrote:

If we are going to teach people inThisBuild in the first example, we should continue with that in all further examples. If we think it's too complicated to explain, we should strip it out of the first example.

So far it seems to me able half-half with and without inThisBuild; my personal vote would be to strip it out, since I've written tons of SBT configs and haven't ever used it, but I don't mind as long as it's consistent throughout

Recap on inThisBuild(...):

  • Was introduced in sbt 0.13.9, so it's a relatively new feature.
  • inThisBuild(...) puts the setting in the build scope, which applies to all subprojects in the build.
  • Because the value is centralized to a setting, it makes it easier to programmatically change it. This is useful for version (e.g. sbt-release uses version in ThisBuild)
  • A newly created subproject will be correct by default without manually adding in the common settings.

Downsides:

  • It requires the user to understand subtle scoping rules around project-scoping vs build level settings.
  • Build level settings are useful for simple pure values, but they won't work for settings and tasks dependent on project-scoped keys such as baseDirectory. In that sense it's more difficult to understand compared to commonSettings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions