.sbt 文件之间的优先级是什么?
What is the priority between .sbt files?
[SBT 文档] 说
Put settings in a .sbt file in a project that isn't checked into version control, such as <project>/local.sbt
. sbt combines the settings from multiple .sbt files, so you can still have the standard <project>/build.sbt
and check that into version control.
但是,如果两个 .sbt 文件定义了相同的设置,哪一个会胜出?
按字母顺序排列:
a.sbt
name := "a"
b.sbt
name := "b"
测试:
% sbt 'show name'
[info] Loading global plugins from /Users/dnw/.dotfiles/.sbt/0.13/plugins
[info] Loading project definition from /Users/dnw/Desktop/t-2015-04-18.1551/project
[info] Set current project to b (in build file:/Users/dnw/Desktop/t-2015-04-18.1551/)
[info] b
从 sbt 0.13.8 开始,我们 might 按字母顺序加载 *.sbt
文件,但我认为我们没有记录这种行为是真实的。因此,此时可能是实现细节。
我们承诺:
- 在同一个文件中设置顺序
- 自动插件指定的插件依赖项
- 自动插件加载的设置,然后
*.sbt
中的设置
所以我建议尽可能使用自动插件。另一种降低设置优先级的方法是在 ThisBuild
范围内。您可以使用自动插件或一些项目来定义:
organization in ThisBuild := "com.example"
[SBT 文档] 说
Put settings in a .sbt file in a project that isn't checked into version control, such as
<project>/local.sbt
. sbt combines the settings from multiple .sbt files, so you can still have the standard<project>/build.sbt
and check that into version control.
但是,如果两个 .sbt 文件定义了相同的设置,哪一个会胜出?
按字母顺序排列:
a.sbt
name := "a"
b.sbt
name := "b"
测试:
% sbt 'show name'
[info] Loading global plugins from /Users/dnw/.dotfiles/.sbt/0.13/plugins
[info] Loading project definition from /Users/dnw/Desktop/t-2015-04-18.1551/project
[info] Set current project to b (in build file:/Users/dnw/Desktop/t-2015-04-18.1551/)
[info] b
从 sbt 0.13.8 开始,我们 might 按字母顺序加载 *.sbt
文件,但我认为我们没有记录这种行为是真实的。因此,此时可能是实现细节。
我们承诺:
- 在同一个文件中设置顺序
- 自动插件指定的插件依赖项
- 自动插件加载的设置,然后
*.sbt
中的设置
所以我建议尽可能使用自动插件。另一种降低设置优先级的方法是在 ThisBuild
范围内。您可以使用自动插件或一些项目来定义:
organization in ThisBuild := "com.example"