Project-specific JVM SBT Parameters

For the project, I need to run SBT with certain JVM parameters ( -Dfile.encoding=UTF-8 and several memory parameters / gc), but I don’t necessarily want to apply the same parameters for every SBT project that I have.

I saw ( sbt-extras ) .sbtopts to .sbtopts (SBT command line options for a specific project) and .jvmopts (JVM SBT options for a specific project) that should support this if they are in the root directory of the SBT project, but the standard version of SBT for Windows (I am using version 0.13.1 ) seems to ignore them.

(The sbt-extras approach appeals to me because, assuming that .sbtopts and .jvmopts tracked in version control, for people who want to build a project, zero SBT configuration is required.)

Is there a current mechanism for specifying project-specific SBT parameters that work with cross-platform?

UPDATE Since I originally asked this question, .sbtopts and .jvmopts are now part of the standard version of SBT for Linux, and sbt-extras is no longer required. However, the Windows version only supports .jvmopts and does not recognize .sbtopts .

+7
sbt
source share
3 answers

This is a recognized limitation in the current version of SBT (v1.0.3, at the time of writing) on ​​Windows (it does not recognize .sbtopts in the project root directory). All versions now support the .jvmopts file.

You can track the status of this problem on the sbt-launcher-package _GitHub-tracker .

0
source share

The sbt-launcher-package project appears (under the sbt projects umbrella , which adds some certainty) is the way to follow.

0
source share

You can change the JVM parameters from your build configuration. As an example:

 fork in run := true javaOptions += "-Xmx1G" 

The fork parameter is important because sbt needs to start a new JVM when performing the launch task, otherwise the parameters will not be applied to the current start.

This explanation assumes that you are using an sbt-style assembly; if you are using a Scala-based assembly (this is what I actually use), you should write it as:

 lazy val yourProject = Project(id = "some-project-id", base = file("./"), settings = Project.defaultSettings ++ Seq( fork in run := true, javaOptions += "-Xmx1G" // ... )) 
-one
source share

All Articles