2

Is there possibility to configure/pass JVM options (ie. javaagent) from build.sbt to stage build - to be used by a generated startup script.

4

2 回答 2

5

If you mean the start script generated by sbt-native-packager, when using the JavaAppPackaging or JavaServerPackaging archetype, you can modify it using the SBT setting bashScriptExtraDefines

See http://www.scala-sbt.org/sbt-native-packager/archetypes/cheatsheet.html?highlight=bashscriptextradefines#overriding-templates

You can use a number of functions and variables which are already defined in the bash start script. addJava adds flags to the java binary. addApp adds flags to the args passed to the running Java application. app_home points at the directory containing the start script.

An example (assuming you have made the newrelic.jar file available to the staged environment via the mappings setting):

bashScriptExtraDefines += """addJava "-javaagent:${app_home}/../newrelic/newrelic.jar""""

Or

bashScriptExtraDefines += "addApp -Dhttps.port=9001"
于 2015-01-14T17:02:35.317 回答
0

This should work in your .sbt file

javaOptions += "-Xmx2G"

Full documentation: http://www.scala-sbt.org/0.13.1/docs/Examples/Quick-Configuration-Examples.html

于 2015-01-14T15:26:37.720 回答