Setting system properties with “sbt run”

后端 未结 4 2016
灰色年华
灰色年华 2020-12-29 06:52

I\'m using a pretty recent version of SBT (seems to be hard to figure out what the version is). I want to pass system properties to my application with sbt run

4条回答
  •  旧巷少年郎
    2020-12-29 07:32

    Thanks for the pointer, this actually helped me solve a somewhat related problem with Scala Tests.

    It turned out that sbt does fork the tests when there are sub-projects (see my code) and some of the tests fail to pick up the system property.

    So in sbt -Dsomething="some value" test, some of the tests would fail when failing to find something in the system properties (that happened to be my DB URI, so it kinda mattered!)

    This was driving me nuts, so I thought I'd post it here for future reference for others (as @akauppi correctly noted, chances are high that "others" may well be me in a few weeks!).

    The fix was to add the following to build.st:

    fork in Test := false

提交回复
热议问题