Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not watch a file for changes in Play Framework

On a Play Framework 2.2 project that is using sbt-buildinfo to create a BuildInfo.scala file when the project is compiled, how can build.sbt be configured so that Play Framework won't watch the BuildInfo.scala file for changes, and won't restart the server if that file changes?

For instance, if a session is started with:

$ sbt ~run

and the server starts in development mode, and then in another terminal window another sbt session is started (to run another subproject, or just to run other sbt tasks), this second sbt session will update the BuildInfo.scala file, and the first sbt session will detect this and reload the Play project.

So the question is how to exclude BuildInfo.scala from monitoring (but still compile it and include it in the distribution package).

Apparently the watchSources configuration option could help, but after reading the documentation I couldn't figure out how to use it to exclude a file.

like image 759
Fernando Correia Avatar asked Jan 17 '15 20:01

Fernando Correia


People also ask

How do I stop play framework?

If you type Ctrl+D, the Play console will quit, but the created server process will continue running in background. The forked JVM's standard output stream is then closed, and logging can be read from the logs/application. log file.

How do you set content type explicitly on play?

Changing the default Content-Type Will automatically set the Content-Type header to text/plain , while: JsonNode json = Json. toJson(object); Result jsonResult = ok(json); will set the Content-Type header to application/json .

What is the default port for Play application?

Overriding configuration with system properties The default is to listen on port 9000 at the 0.0. 0.0 address (all addresses).


1 Answers

To remove a particular file from being watched you can do in build.sbt:

watchSources := watchSources.value.filter { _.getName != "BuildInfo.scala" }

I tried to reproduce basic setup, and for me the BuildInfo.scala file is not watched. You can see the list of watched sources by issuing show watchSources.

like image 57
lpiepiora Avatar answered Sep 20 '22 12:09

lpiepiora