Search code examples
sbtsbt-native-packager

Command line options in SBT native packager


When you package a command-line application in SBT using the sbt-native-packager plugin, you get a wrapper script that has additional command line options that looks something like this:

  -h | -help         print this message
  -v | -verbose      this runner is chattier
  -d | -debug        set sbt log level to debug
  -no-version-check  Don't run the java version check.
  -mem <integer>     set memory options in MB (default: , which is -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m)
  -jvm-debug <port>  Turn on JVM debugging, open at the given port.

  # java version (default: java from PATH, currently java version "1.7.0_21")
  -java-home <path>         alternate JAVA_HOME

  # jvm options and output control
  JAVA_OPTS          environment variable, if unset uses ""
  -Dkey=val          pass -Dkey=val directly to the java runtime
  -J-X               pass option -X directly to the java runtime
                     (-J is stripped)

  # special option
  --                 To stop parsing built-in commands from the rest of the command-line.
                     e.g.) enabling debug and sending -d as app argument
                     $ ./start-script -d -- -d

Is it possible to either selectively disable some of this options or remove them altogether from the packaged application?


Solution

  • First of all, there isn't any way to disable single command line options.

    However, you can do a few other things:

    1. As Shyam mentioned, you can override the start script
    2. The second option would be to use the -- separator. Everything before that will be parsed by the script, and everything after will be appended as command line arguments to the application.

    If you have a use case that may be of interest for general availability, you can open a feature request.