Can I avoid compiling sources twice when running p

2019-03-18 16:45发布

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 those two compilation steps?

As far as I know, the eclipse plugin also uses sbt to build the project so maybe there is a way to execute the play "run" command inside eclipse?

(I am asking because my laptop is not very fast and compilation takes some time, and I would like to have the "Fast turnaround" as advertised on the play webpage ;)

3条回答
太酷不给撩
2楼-- · 2019-03-18 17:15

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.

查看更多
看我几分像从前
3楼-- · 2019-03-18 17:20

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

查看更多
劫难
4楼-- · 2019-03-18 17:26

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
查看更多
登录 后发表回答