[英]sbt multi-module project: dependence between projects
I am new to Scala, so I hope this question is not too naive. 我是Scala的新手,所以我希望这个问题不要太幼稚。
Suppose I have a multi-module sbt-project and there is a dependence between projects. 假设我有一个多模块的sbt-project,并且项目之间存在依赖关系。
lazy val core = (project in file("core")).
settings( ... )
lazy val utils = (project in file("utils")).
settings( ... ).dependsOn(core)
The question, does .dependsOn(core)
mean that if I do projects utils; compile
问题是, .dependsOn(core)
表示如果我进行projects utils; compile
projects utils; compile
it is going to compile
the core
beforehand (and use its latest version)? projects utils; compile
它会事先compile
core
(并使用其最新版本)?
I am asking this, since in practice I don't see this behavior (and I want it). 我问这个问题,因为在实践中我看不到这种行为(并且我想要)。
You are looking for the aggregate
method. 您正在寻找aggregate
方法。 Like this: 像这样:
lazy val utils = (project in file("utils")).
settings( ... ).dependsOn(core).aggregate(core)
The aggregate method here causes all tasks run on utils
to also be run on core
(update, etc...). 这里的聚合方法使所有在utils
上运行的任务也可以在core
上运行(更新等)。 If you want to disable a task from running on an aggregated project you can check out the documentation here 如果要禁用任务在聚合项目上运行,可以在此处查看文档。
Yes, you should see this behavior (and I do see it in practice). 是的,您应该会看到这种行为(我在实践中确实会看到)。 As the linked documentation says (note that the roles of util
and core
are opposite there: core
depends on util
): 如链接文档所述(注意util
和core
的作用相反: core
取决于util
):
This also creates an ordering between the projects when compiling them; 在编译项目时,这还会在项目之间创建顺序。 util must be updated and compiled before core can be compiled 必须先更新并编译util,然后才能编译内核
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.