Play framework. no need to compile

前端 未结 3 1880
野性不改
野性不改 2021-02-09 16:07

I was introduced to the Play framework, and one of the amazing things I found about it is that there is no need to compile the project. You only need to save the edited files an

相关标签:
3条回答
  • 2021-02-09 16:25

    When running in DEV mode, Play works by checking the last modified date of the java files, and cross referencing them with the .class files that are generated at run time. If it recognises something has changed, then it recompiles them, at runtime.

    In Play 1.x - the recompilation is done using the eclipse jdt compiler (org.eclipse.jdt.internal.compiler.Compiler). If you want to see the code from Play 1.x, just look at the following class - https://github.com/playframework/play/blob/master/framework/src/play/classloading/ApplicationCompiler.java

    In Play 2.x, it looks as though Play does it by interlinking with the SBT tool. Check this out - https://github.com/playframework/Play20/blob/master/framework/src/play/src/main/scala/play/core/system/ApplicationProvider.scala

    0 讨论(0)
  • 2021-02-09 16:30

    If you are talking about Play framework 1.x, it has an application class manager, which automatically load the java source file and compile it into byte code (using Eclipse Java Compiler), in additional it will enhance the compiled code using Javassist. Check the codes in https://github.com/playframework/play/tree/master/framework/src/play/classloading.

    0 讨论(0)
  • 2021-02-09 16:31

    Although you didn't mention which version of Play amazed you so much in simplest words it can be described that way: Play in development mode watches all files that belongs into your app, and in case of any change it recompiles required parts. Therefore DEV should not be used for production - as it is redundant loss of the performance. Otherwise: when you'll start your application in production mode it will avoid immediate recompiling, however it will gain the performance.

    In Play 2 running the application is development mode done with

    play run
    

    or

    play ~run
    

    (first command recompiles code after next page hit, second after next file change)

    Running application in production mode can be done with

    play start
    
    0 讨论(0)
提交回复
热议问题