Difference from `{.}/*:name` and `*/*:name` in sbt

2019-04-28 17:46发布

问题:

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?

回答1:

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.



标签: scope sbt global