Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having sbt to re-run on file changes - The `~ compile` equivalent for `run`

Tags:

scala

sbt

I know it's possible to re-compile or re-run tests on file changes. I want know to if it's possible to perform something similar for the run command. ~ run does not work. (That makes sense since the run never finishes).

Is there a way to create a task that watches for file changes, quit the running server and relaunch it ?

If not what other tool, would you suggest to get the same behaviour ?

like image 778
jackdbernier Avatar asked Nov 16 '14 23:11

jackdbernier


People also ask

Does sbt run compile?

sbt is a popular tool for compiling, running, and testing Scala projects of any size. Using a build tool such as sbt (or Maven/Gradle) becomes essential once you create projects with dependencies or more than one code file.

Does sbt test compile?

One task that you don't need to fork for is compilation. sbt does the necessary steps for these to work correctly, and you don't need to fork to compile. Again, the fork setting can apply to the run , run-main , and test tasks, with run and run-main sharing the same setting ( run ).

What does sbt reload do?

object Reload extends CancelWatch with Product with Serializable. Action that indicates that the watch should pause while the build is reloaded. This is used to automatically reload the project when the build files (e.g. build.


1 Answers

You will have to bring in an external project like sbt-revolver

https://github.com/spray/sbt-revolver

like image 124
Gangstead Avatar answered Sep 28 '22 18:09

Gangstead