2

I have a play framework project which has a client library as a submodule. I'm using flyway for database migrations. When I use a command for flyway (such as sbt flywayMigrate), it runs that command twice, once against the root project, and once against the client library submodule.

Is there a way to run an SBT command against only the project, and not any of the submodules?
sbt clientLibrary/flywayMigrate will run the command against only the submodule, but sbt root/flywayMigrate runs the command against both.

I've seen this answer which addresses running only one submodule, but does not help with running only the main module and no submodule.

EDIT: I do have the client library in the aggregate for the root, and removing it runs commands just for the root by default. However I think having all the modules run by default is desirable, and I'd like to specify module exclusion rather than inclusion.

Pavel
  • 1,519
  • 21
  • 29
kag0
  • 5,624
  • 7
  • 34
  • 67
  • Maybe that will help you? http://stackoverflow.com/questions/39551712/sbt-unidoc-how-to-exclude-a-sub-module-from-a-rootproject – Alexey Soshin Sep 21 '16 at 18:11
  • @AlexeySoshin it does point me in a direction, I'll update my question with more details. – kag0 Sep 21 '16 at 18:31

1 Answers1

4

See http://www.scala-sbt.org/0.13/docs/Multi-Project.html#Aggregation:

In the project doing the aggregating, the root project in this case, you can control aggregation per-task. For example, to avoid aggregating the update task:

lazy val root = (project in file(".")).
  aggregate(util, core).
  settings(
    aggregate in update := false
  )

In your case, set aggregate in flywayMigrate := false instead. To do this just once,

sbt "; set aggregate in (ThisBuild, flywayMigrate) := false; root/flywayMigrate"

should work.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487