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

后端 未结 1 1665
时光说笑
时光说笑 2021-02-12 11:23

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 paramete

相关标签:
1条回答
  • 2021-02-12 12:07

    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 讨论(0)
提交回复
热议问题