简体   繁体   中英

hot swap in sbt project without play-plugin

When I am using play framework, every time I've changed the code, it will take effect automatically by re-compile the code.

However, when I'm using sbt to run a project without play-plugin, it won't take effect.

I'm wondering if there were a way to make sbt project hot swap the changed code.

My build.sbt is as below:

version in ThisBuild := "1.0-SNAPSHOT"

scalaVersion in ThisBuild := "2.11.6"

lazy val `frontend` = (project in file("frontend")).
  enablePlugins(PlayScala).
  enablePlugins(DockerPlugin).
  settings(
    name := "frontend",
    libraryDependencies ++= Dependencies.frontend
  ).dependsOn(`api`).aggregate(`api`)

lazy val `backend` = (project in file("backend")).
  enablePlugins(JavaAppPackaging).
  enablePlugins(DockerPlugin).
  settings(
    name := "backend",
    libraryDependencies ++= Dependencies.backend ++ Seq(cache, ws)
  ).dependsOn(`api`).aggregate(`api`)

lazy val `api` = (project in file("api")).
  settings(
    name := "api",
    libraryDependencies += ws
  )

And what I have configured in intellij idea is like below as a sbt task(I can't post images by now):

"project backend" ~run

However, every time I've changed the code in backend, It won't take effect after I've call backend from the frontend.

I'm wondering how I can solve the problem. Thanks for your guys' help.

您可以通过如下方式调用sbt来自动重新编译任何更改: sbt ~compile

If you use ~run, on every change the changeed classes will be compiled and project rerun again. If it does not work, you might explain more about your project and structure.

Open two SBT window.
The one run ~compile , and another run ~run . Hope it will be help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM