0

I want to pass an environment variable when running container:start from sbt. So I have tried adding

 javaOptions in container := Seq("-Dmyvar=xxx")

to build.scala, as outlined in the xsbt plugin documentation. But this is having no effect when I run container:start. Can someone suggest what I might be missing?

Thanks Des

user79074
  • 4,937
  • 5
  • 29
  • 57

1 Answers1

2

If you're using xsbt-web-plugin v1.0.x, then your approach is correct:

javaOptions in container := Seq("-Dmyvar=xxx")

You can find a working example of this option in the java-options test case.

EDIT: See also this example, which shows the above -Dmyvar=xxx used with v1.0.0-M7 in a Scalatra environment.

With xsbt-web-plugin v0.9 and earlier, you'll need to pass your JVM argument directly to sbt:

sbt -Dmyvar=xxx
earldouglas
  • 13,265
  • 5
  • 41
  • 50
  • Am using it with the scalatra project and haven't been able to get it working with v1.0.x. See: http://stackoverflow.com/questions/25991296/xsbt-plugin-1-0-0-m7-and-scalatra – user79074 Sep 23 '14 at 09:18
  • 1
    Here's an example that shows this working with Scalatra 2.3.0 and xsbt-web-plugin 1.0.0-M7: https://github.com/earldouglas/so-25948575 – earldouglas Sep 24 '14 at 15:56
  • The example link above has been changed to https://earldouglas.com/ext/stackoverflow.com/questions/25948575/ – earldouglas Mar 19 '18 at 14:40