Artur Gajowy Artur Gajowy - 1 year ago 117
Scala Question

SBT aggregating subproject

Given a project structure:

rootProject
aggregatingSubProject
subA
subB
subC


How do I run the
package
task for
aggregatingSubProject
and all its aggregated projects, without specifying them by hand?

So far I can only have
subA
and
subB
built when doing
package
in the
rootProject
- regardless if I put
.aggregate(subA, subB)
in
aggregatingProject
's
build.sbt
.

I need the
rootProject
to define common settings for the build and I want to build multiple projects (some aggregating other projects, like
aggregatingSubProject
does) in a single build.

Using sbt
0.13.16
.

Answer Source

Given this in build.sbt:

val rootProject = project in file(".")
val aggregatingSubProject = project
val subC = project

and this in aggregatingSubProject/build.sbt:

aggregateProjects(subA, subB)

val subA = project
val subB = project

You can run aggregatingSubProject/package and get:

> 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.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download