If your main project combines objects, for example:
lazy val root = Project("name", file(".")) .aggregate(module1, module2, macros)
then any command invoked by this root project will be executed for all subprojects. If you call the inspect clean command in your sbt session, you will see in the Related section all the subprojects that are related to this clean
Side notes in comments
aggregate and dependsOn are different commands for different purposes. The purpose of aggregation is to execute commands invoked in the root project. In my example, by invoking the test command in my root project, this command will also be executed for module1 module2 and macros . If you want to disable this behavior with the following setting:
aggregate in test := false
An aggregated project is independent of the code in them. It is usually used in a root project, for example, not to call test for each project, but to call it root. Remember that in the case of aggregation commands will be executed in parallel.
And dependsOn means that your project will depend on code from another project. And in this case, SBT will execute the sequentialy command to compile your root project, which dependsOn some modules, it must compile these modules in the first step, the root project.
source share