Search code examples
scalasbtsprayakka-httpsbt-revolver

How to run sbt-revolver with a Scala project?


So I'm reading the documentation for sbt-revolver since I'm interest in using its:

Triggered restart: automatically restart your application as soon as some of its sources have been changed

It says in the documentation that it should work with any scala project ( I'm running an Akka Http) as long as it has a class with a main method and that we just need to plug in project/plugins.sbt:

addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.0")

So I did that then I went with terminal to root folder, ran sbt wait it to load and then run, now I made a small change in some file that loads and html with some <h1> but changes aren't reloaded, what am I missing?

Update

So after running sbt in terminal, then I run ~reStart and it seems to exit the server:

root Server online at localhost:8080 root Press RETURN to stop... root ... 
finished with exit code 0  

Solution

  • You have two options, if you need only run, no need the revolver plugin, just start it with

    ~run
    

    If you need revolver, you should use

    ~reStart
    

    as it is stated on their homepage too:

    You can use ~reStart to go into "triggered restart" mode. Your application starts up and SBT watches for changes in your source (or resource) files. If a change is detected SBT recompiles the required classes and sbt-revolver automatically restarts your application.

    Note, you can specify any command to be run on each change of source files after ~.