kag0
kag0

Reputation: 6054

Flyway migration (multi project): run SBT command for main module, but not submodule

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.

Upvotes: 2

Views: 907

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170859

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.

Upvotes: 4

Related Questions