Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass javaOptions to "play run" through Build.scala

I would like to pass a -Dconfig.file=conf/dev.conf parameter to my application through Build.scala when I use the run command.

I am trying to put something like in this in my Build.scala:

val mySettings = Seq(
  (javaOptions in run) ++= Seq("-Dconfig.file=conf/dev.conf")
)

val main = play.Project(appName, appVersion, appDependencies).settings(
  mySettings: _*
)

But it doesn't - from what I've gathered this is because SBT doesn't fork a new JVM when I use run. Any workarounds except of setting an environment variable?

like image 830
thesamet Avatar asked Aug 16 '13 20:08

thesamet


1 Answers

The matter seems to be that Play runs in the same JVM as the SBT JVM so the Java options set in SBT are not used.

You can try something like:

  • Use fork in run := true so that a new JVM is spawn, using the Java options you give

  • Launch SBT with -Dconfig.file=conf/dev.conf

  • Set system property manually before running the app in the same JVM: System.setProperty("config.file","conf/dev.conf")

I'm not sure all these solutions work but it's worth trying them

like image 158
Sebastien Lorber Avatar answered Oct 13 '22 23:10

Sebastien Lorber