Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing JVM args through sbt

Tags:

sbt

I'm trying to add a 3rd party jar to my java library path. If I invoke sbt with -Djava.library.path=a-3rd-party-lib.jar, then it works for the first invocation of run-main MyClass inside sbt, but thereafter the 3rd party code complains that the jar is not in the java library path. I have also tried adding javaOptions += "-Djava.library.path=a-3rd-party-lib.jar" to my build.sbt file, but this hasn't worked (even for the first run). Qualifying this command as javaOptions in (Test,run) += "-Djava.library.path=a-3rd-party-lib.jar" (as seen in the docs) hasn't worked either.

Am I doing something wrong, or is this a strange bug?

FYI I'm using sbt 0.13.0

like image 414
twolfe18 Avatar asked Sep 27 '13 21:09

twolfe18


1 Answers

javaOptions only takes effect if you fork run and sbt does not fork by default. See the Forking documentation for details, but forking is enabled for run and runMain with:

fork in run := true
like image 52
Mark Harrah Avatar answered Sep 27 '22 20:09

Mark Harrah