Can I avoid compiling sources twice when running play2 and eclipse?

后端 未结 3 1984
太阳男子
太阳男子 2021-02-07 22:54

Currently I am running eclipse and play (with ~run) at the same time. When I change a file it will be compiled by play and by eclipse.

Is it possible to avoid one of tho

3条回答
  •  清歌不尽
    2021-02-07 23:17

    I have not yet tried to run the play run sbt task in eclipse.

    BUT you can run the server directly from eclipse.

    1. Add "target/scala-2.9.1/classes" to your class path, use filters to include only your assets. (Project Properties, Java Build Path)
    2. Choose "Run Configurations..." from the Run-Button-Menu.
    3. Create a new "Java Application" configuration with your favourite name.
    4. Main Tab: Use "DebugStart" as your main class
    5. Arguments Tab: Configure any "-Dconfig.file=..." "-Dlogger.file" options you might need in VM arguments
    6. Classpath Tab: Add the conf directory to the classpath (Advanced/Add Folders)

    Create DebugStart.scala with:

    import play.core.server.NettyServer
    import java.io.File
    import play.core.SBTLink
    import play.core.TestApplication
    import play.api.test.FakeApplication
    import play.api.test.TestServer
    
    object DebugStart {
      def main(args: Array[String]) {
        val app = FakeApplication()
        val server = TestServer(9000, app)
        server.start()
      }
    }
    

    You can now start the app with run or debug. If you use debug, you can perform some code changes without any restart.

    My version of DebugStart.scala actually contains some platform dependent hackish code to kill any running process, so that I can just hit F11 or CTRL+F11 to restart the application.

    To ensure that your assets/sources are up to date run:

    > sbt
    ...
    [your project] $  ~ ;play-copy-assets;sources
    

提交回复
热议问题