SBT汇总子项目

时间:2017-10-02 13:21:31

标签: scala sbt

给定项目结构:

rootProject
  aggregatingSubProject
    subA
    subB
  subC

如何为package及其所有聚合项目运行aggregatingSubProject任务,而不是手动指定它们?

到目前为止,在subA中执行subB时,我只能构建packagerootProject - 无论我将.aggregate(subA, subB)放在aggregatingProject中} build.sbt

我需要rootProject来定义构建的常用设置,我想在一个构建中构建多个项目(一些聚合其他项目,如aggregatingSubProject)。

编辑:我需要在没有指定根build.sbt中的所有子项目的情况下执行此操作。我想在aggregatingSubProject / build.sbt中定义subA和subB。

使用sbt 0.13.16

1 个答案:

答案 0 :(得分:3)

build.sbt

中给出了这一点
val rootProject = project in file(".")
val aggregatingSubProject = project
val subC = project

,这在aggregatingSubProject/build.sbt

aggregateProjects(subA, subB)

val subA = project
val subB = project

您可以运行aggregatingSubProject/package并获取:

> aggregatingSubProject/package
[info] Updating {file:/s/t-subaggregate/}subB...
[info] Updating {file:/s/t-subaggregate/}aggregatingSubProject...
[info] Updating {file:/s/t-subaggregate/}subA...
[info] Done updating.
[info] Packaging /s/t-subaggregate/aggregatingSubProject/subA/target/scala-2.12/suba_2.12-0.1-SNAPSHOT.jar ...
[info] Done updating.
[info] Done packaging.
[info] Packaging /s/t-subaggregate/aggregatingSubProject/subB/target/scala-2.12/subb_2.12-0.1-SNAPSHOT.jar ...
[info] Done packaging.
[info] Done updating.
[info] Packaging /s/t-subaggregate/aggregatingSubProject/target/scala-2.12/aggregatingsubproject_2.12-0.1-SNAPSHOT.jar ...
[info] Done packaging.