Skip to content

Scope of name #2636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions _overviews/FAQ/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,36 @@ setting in a multi-project build.

For example, if you add this to your `build.sbt`:

scalaVersion := "2.13.7"
scalaVersion := "2.13.10"

that's a "bare" setting, and you might expect it to apply build-wide.
But it doesn't. _It only applies to the root project._

In many cases one should instead write:

ThisBuild / scalaVersion := "2.13.7"
ThisBuild / scalaVersion := "2.13.10"

Other possibilities include:
Conversely, you should not write:

ThisBuild / name := "sample"

which will result in a warning:

[warn] there's a key that's not used by any other settings/tasks:
[warn]
[warn] * ThisBuild / name
[warn] +- sample-project/build.sbt:11

For your quick single-project build with bare settings, the minimal settings are:

scalaVersion := "2.13.10"
organization := "sampler"
version := "0.1"
name := "sample" // must not be scoped to ThisBuild

scalacOptions ++= Seq("-Werror", "-Xlint") // append to options

Other possible solutions to provide a setting everywhere include:

* the common settings pattern, where you put shared settings
in a `val`, typically named `commonSettings`, and then
Expand Down