Can someone explain me the difference between writing these 2 lines:
resolvers in ThisBuild ++= appResolvers resolvers in Global ++= appResolvers
Can someone explain me the difference between writing these 2 lines:
resolvers in ThisBuild ++= appResolvers resolvers in Global ++= appResolvers
Read Scopes for the full explanation.
I'll quote relevant parts:
There are three scope axes:
- Projects
- Configurations
- Tasks
Scoping by project axis
If you put multiple projects in a single build, each project needs its own settings. That is, keys can be scoped according to the project.
Global scope
Each scope axis can be filled in with an instance of the axis type (for example the task axis can be filled in with a task), or the axis can be filled in with the special value Global.
Referring to scoped keys when running sbt
*
can appear for each axis, referring to theGlobal
scope.
{.}/test:full-classpath
sets the project axis to "entire build" where the build is{.}
.{.}
can be writtenThisBuild
in Scala code.Referring to scopes in a build definition
name in Global := "hello"
(
name in Global
implicitly converts the scope axisGlobal
to a scope with all axes set toGlobal
; the task and configuration are alreadyGlobal
by default, so here the effect is to make the projectGlobal
, that is, define*/*:name
rather than{file:/home/hp/checkout/hello/}default-aea33a/*:name
)
So as written above, Global
sets all three axes to Global
whereas ThisBuild
sets only the project axis to {.}
. This might make sense if you combine ThisBuild
with other axis like configuration:
name> set name in Test in ThisBuild := "test-name" [info] Defining {.}/test:name
This would probably be used in a plugin:
resolvers in Global ++= appResolvers
Whereas this could appear in your build definition:
resolvers in ThisBuild ++= appResolvers
thereby letting you override global default offered by plugin.
Within the same build definition, using either one will most likely have equivalent effect, because they are the bottom two in the delegates list.