开发者

How can I pass JVM options to SBT to use when running the app or test cases?

开发者 https://www.devze.com 2023-03-29 12:43 出处:网络
I would like to specify JVM options when running my app or the tests for the app through SBT. Specifically, I need to be able to give the JVM the -Djava.security.policy parameter so that my policy is

I would like to specify JVM options when running my app or the tests for the app through SBT. Specifically, I need to be able to give the JVM the -Djava.security.policy parameter so that my policy is loaded a开发者_高级运维nd used for the test.

How can I do this with SBT?


With xsbt, you could run your test in a forked JVM (because of one of the reasons mentioned in "Running Project Code".

If you are using a forked jvm:

specify the configuration to affect only the main or test run tasks:

scala javaOptions in (Test,run) += "-Xmx8G" 

You should be able to specify any other options to that JVM through javaOptions.


The OP David Eagen reports that the following configuration didn't work at first, not because of the sbt options, but because of the path:

lazy val escacheServer = 
  Project( "escache-server", 
           file("server"), 
           settings = buildSettings ++ Seq(resolvers ++= 
                        Seq(scala_tools_snapshots, typesafe_repo), 
                        libraryDependencies ++= escacheServerDeps, 
                        javaOptions in run += "-Djava.security.policy=jini.policy", 
                        fork in run := true 
                      ) 
         ).dependsOn(escache) }

It looks like my problem was that jini.policy wasn't found in the current directory.
I set the full path and now it runs.

0

精彩评论

暂无评论...
验证码 换一张
取 消