Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT: How to trigger separate actions when files change in two separate subprojects

Tags:

scala

sbt

My build.sbt looks like this:

val client = project.in(file("client"))

val server = project.in(file("server"))

The main project comprises two separate projects, client and server. I would like to develop them simultaneously: I need both of them built and the server running when I'm working. Each project has their own additional build steps: client needs a packageJS after being compiled, while server needs a container:restart.

However, doing ~; restartServer; restartClient from the root directory doesn't do what I want, since it listens to either subproject and always restarts both of them, and in my case causes a restart loop since one subproject dumps files into the other subproject for it to use.

Is there anyway to do this "~restartXXX" in both subprojects simultaneously, so I can edit either of them and it will restart only the edited project?

like image 357
Li Haoyi Avatar asked Feb 24 '14 04:02

Li Haoyi


1 Answers

Have you tried: ~ all restartServer restartClient.

In sbt 0.13.2-M2 (and I think sbt 0.13.1, but not sure), there is a new all command which will run specified tasks in parallel. Combined with ~, you can ensure you run more than one task on a change.

like image 55
jsuereth Avatar answered Nov 06 '22 01:11

jsuereth