Cannot seem to run Play application in a forked JVM from within SBT

Viewed 106

I have a Scala Play Framework web-application (using Scala v2.13.7 and Play v2.8.8) built using SBT (v1.5.5).

My build.sbt includes the following:

lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.settings(

  // etc.

  fork := true,
  javaOptions ++= Seq(
    "-Xms1G",
    "-Xmx8G",
  ),
)

However, a separate JVM for the web-application is not spawned when I execute sbt run, and the memory settings are those of the SBT JVM (-Xms1024m and -Xmx1024m).

Does the PlayScala plugin interfere with or disable forking when running the web-application itself? Can I force the web-application to use a forked JVM from within SBT?

2 Answers

Based on the sbt documentation, Forked JVM Options, you may want to do something like:

lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.settings(

  // etc.

  javaOptions ++= Seq(
    "-Xms1G",
    "-Xmx8G",
  ),
  fork := true,
  run / javaOptions += "-Xms1G -Xmx8G",
)

I'm not very familiar with play, but this should resolve the issue you're facing.

Sparing myself a long investigation on my part, if all you want to do is affect java options, set them (all in one or one per line is ok) in a file named .jvmopts in the sbt project root folder (-as mentioned elsewhere already).

Related