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

后端 未结 3 1982
太阳男子
太阳男子 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:02

    You can turn off Build Automatically from the Project menu without losing any of the IDE functionality. Binaries will be built only by Sbt (on the command line).

    A detailed guide for setting-up Play 2 with Scala IDE can be found on the Scala IDE website: http://scala-ide.org/docs/tutorials/play20scalaide20/index.html

    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2021-02-07 23:17

    IntelliJ Idea 12 (Leda) is coming soon. I'm using 11 for a while and there's no such problems but new version will offer much better Play 2.0 integration.

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