给定项目结构:
rootProject
aggregatingSubProject
subA
subB
subC
如何为package
及其所有聚合项目运行aggregatingSubProject
任务,而不是手动指定它们?
到目前为止,在subA
中执行subB
时,我只能构建package
和rootProject
- 无论我将.aggregate(subA, subB)
放在aggregatingProject
中} build.sbt
。
我需要rootProject
来定义构建的常用设置,我想在一个构建中构建多个项目(一些聚合其他项目,如aggregatingSubProject
)。
编辑:我需要在没有指定根build.sbt中的所有子项目的情况下执行此操作。我想在aggregatingSubProject / build.sbt中定义subA和subB。
使用sbt 0.13.16
。
答案 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.