6

From some sbt document(e.g. scopes), I see:

{.}/*:name

means name in entire build(use name in ThisBuild to define it)

*/*:name

means name in global project(use name in Global to define it)

(PS: I ignored the config part *:)

But, I still don't know what is the difference between them, they seem exactly the same to me.

Is there any thing I can do with one rather than another one?

Freewind
  • 193,756
  • 157
  • 432
  • 708
  • I've read this question, but still not clear: http://stackoverflow.com/questions/18289766/what-is-the-difference-between-thisbuild-and-global-scopes – Freewind Sep 15 '14 at 06:25

1 Answers1

2

Whatever version you specified in ThisBuild will be applied to all projects in your build, overriding anything that was possibly defined in Global.

For example: Key "version"

For Global scope it was defined in Defaults.scala with value "0.1-SNAPSHOT".

For your projects in this build you might want to overwrite that with:

version in ThisBuild := "3.0.1"

So, because [{.}/*:version] has precedence over [*/*:version], whenever you get "version" in your projects, you fetch "3.0.1" instead of "0.1-SNAPSHOT".

This pretty much explains the difference and how you could use one and not the other.

Renat Bekbolatov
  • 329
  • 4
  • 11
  • 1
    So `Global` has bigger scope than `ThisBuild`, because it can be a default value across different builds (e.g. defined in sbt, or in a sbt plugin), but `ThisBuild` is just reference current build, and can override the global default value? – Freewind May 06 '15 at 05:27
  • Why would one want different values in Global and ThisBuild? – Konstantin Pelepelin Oct 05 '17 at 23:30
  • I also had a hard time in understanding this, but once it was mentioned that a plugin can define some setting in the Global scope it got clearer to me. Apart of plugins I don't see any use cases for using Global vs ThisBuild. – Alexander Arendar Dec 05 '17 at 14:32