Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run "clean" all dependent SBT subprojects

I have an SBT project, specifically a Play Framework 2.1 project, that has a number of subprojects specified in the configuration. The dependencies seem to work fine when compiling, but "clean" only seems to clean the currently selected project, not including its dependencies. Is there any way to clean both the selected project and its dependent subprojects?

like image 347
Ben Dilts Avatar asked Aug 06 '13 23:08

Ben Dilts


1 Answers

If your main project aggregates subjects, like this:

lazy val root = Project("name", file("."))
    .aggregate(module1, module2, macros)

then any command called on this root project will be executed for all subprojects. If you call inspect clean command in your sbt session, you'll see, under Related section all subprojects which relates on this clean

On the side note in the comment

aggregate and dependsOn are different command for different purposes. The purpose of aggregation is in running commands called on the root project. In my example by calling test command on my root project, this command will be executed also for module1 module2 and macros. If you want to turn off such behaviour with the following setting:

aggregate in test := false

Aggregated project are independent on the code in them. It's usually used on the root project, nfor example not to call test on each project, but to call it on root. Remeber that in case of aggregation commands will be executed in parallel.

And dependsOn means that your project will depend on the code from other project. And in this case SBT will execute command sequentialy, in order to compile your root project, which dependsOn some modules, it should compile those modules at first step, the the root project.

like image 51
4lex1v Avatar answered Oct 05 '22 23:10

4lex1v