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
Document usage of ThisBuild
over Global
#3652
Comments
The difference between Global and build-level is relevant when you have more than one build. In that case you see that what you refer to as "true at the global level (organization, license, et cetera)" isn't (always) true - any build you add could easily have a different organization, license, et cetera. The way I see it is Global scope should be used only for:
Therefore I think the absence of |
I agree with this. I'm happy to close this ticket so long as this is explained in the sbt docs and people know that they should scope in |
I agree. We'll use this issue to track that documentation improvement. |
inGlobal
to allow scoping settings globallyThisBuild
over Global
I don't see how a doc on this topic can be a contribution. It needs to be written by someone with a good understanding of scoping. |
At the risk of necroing this issue, I have found myself writing various sbt plugins and I wan't to make sure that I am fully clear on what the distinction between So one part I find slightly confusing is this statement
Can you clarify what you mean when you say "more than build". Are you talking about the typical case of having multiple sbt projects in a single sbt build with each project having its own name, generating its own artifact etc etc or is the some strict terminology definition of "build" that I am unaware of? Or by build, do you literally mean different arbitrary sbt builds (i.e. different directories having their own For context I am doing a change to this SBT plugin (see pjfanning/sbt-source-dist#15) and I wan't to make sure that I am actually correct in my understanding of |
It's not a well-documented feature, but an sbt build (directory with In addition to that, there's sort of a cultural/conventional differences between the two. Set aside config-scoping and task-scoping, the strength of scoping is:
So what we normally recommend for plugin authors to scope is use However, plugin authors should be careful at mutating the Global keys provided by sbt or other plugins, because essentially the values are going to be plugin-load-order-dependent, which is annoying. |
Many thanks for the detailed reply!
Is this the case even for keys which have a high chance of being set for plugin consumers, i.e. in this PR pjfanning/sbt-source-dist#15 I am trying to fix things by putting the keys in global scope (as you state) however it means that when a plugin consumer wants to set the key they need to use Also on another point when it comes to plugin authors mutating the values of keys created by other sbt plugin/s (assuming the plugin author has those sbt plugins specified in Or does it just really depend the specific usecase? The mental model I have in my head currently (which I want to verify) is that you would use |
My comment regarding For sbt-source-dist, I'd actually put everything in lazy val root = (project in file("."))
.enablePlugins(SourceDistPlugin)
I think it depends.
|
So I just had a discussion with @jrudolph and he clarified the confusion I had in my head specifically wrt to Does it make sense to update the sbt website to make this more clear as there does seem to be various distinctions regarding best practice? |
Yea. If you have ideas on what you want to write, feel free to update https://github.com/sbt/website/blob/develop/src/reference/02-DetailTopics/05-Plugins-and-Best-Practices/03-Plugins-Best-Practices.md#scoping-advice. |
(edited by @dwijnand, previous title: "Add
inGlobal
to allow scoping settings globally")problem
inThisBuild
is a standard operation in anybuild.sbt
and sbt plugin. However, there's no counterpart for scoping inGlobal
.expectation
I would like to have an
inGlobal
operation to scope there important keys that are true at the global level (organization, license, et cetera).This would be the implementation of
inGlobal
, placed inProject.scala
:notes
I would like to add this to the Scala Center spree that we're having at Lambda World next week.
sbt version: 0.13.x and 1.x
The text was updated successfully, but these errors were encountered: