Toto
Toto

Reputation: 397

Hot reloading of Play Framework (2.4), sbt (0.13.17) and reason for complete project being entirely recompiled

Something seems currently wrong with my web application project and its internal dependencies: if I modify the body of a public, non-static Java method for certain classes, my whole project gets recompiled. This is a huge waste of my time, how can I go about debugging this and fix it ?

If possible I would like sbt to tell me the incremental compile dependency tree (ie: modifying "myMethod" triggers recompile classes A1 and B1, recompiling A triggers recompile A2, recompiling B1 triggers recompile B2, and so on. This would probably give me some clue. Does this even exist ?

Upvotes: 0

Views: 327

Answers (1)

Chaitanya
Chaitanya

Reputation: 3638

There is nothing wrong with Play framework when changing/modifying the code leads to re-compilation. This is basically a feature of Play framework called "Hot Reloading".

Now coming to the second part of your question, you need to understand how play hot reloading works

Let's say your play server is running and you make a code change. Then following steps are followed

  1. It compiles your class file and checks for any compilation issue.
  2. Then compiles remaining code to check if the new code change is breaking any other part of the code.
  3. If there is any compilation issue, it will throw an exception.
  4. Assuming the compilation succeeded, we need to update the loaded classes in the JVM. For that we just remove the old application classloader, and create a new one with the updated classes.
  5. Play application is restarted.

To summarize, play framework discards the old classloader and creates a new one with the updated classes and hence complete project is recompiled again.

Hope that answers your question !!!

Upvotes: 2

Related Questions