I've put some javaOptions in build.sbt which are used while running tests. These are working as expected.
javaOptions in Test += "-Dconfig.file=conf/test.conf"
javaOptions in Test += "-Duser.timezone=UTC"
I want to use something similar during runtime as well. I've tried the following and they don't work at all:
javaOptions in Runtime += "-Duser.timezone=UTC"
javaOptions in run += "-Duser.timezone=UTC"
I'm running the tests/application from command line using "activator test" and "activator run". Since the javaOptions are not working, the only other option is to pass them in the command line as: "activator run -Duser.timezone=UTC". I prefer not passing the command line arguments.
javaOptions
are only applied to a forked JVM.
> help javaOptions
Options passed to a new JVM when forking.
The reason why it is working in your tests is that Playframework by default runs your test in a forked JVM in parallel.
> show test:fork
[info] true
If you want to achieve this for the run task as well you can use a forked JVM as well. Add the following to build.sbt
file:
fork in run := true
See chapter on Forking in SBT documentation for further details: http://www.scala-sbt.org/0.13/docs/Forking.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With