什么优先 SBT_OPTS 或 .sbtopts?

What takes precedence SBT_OPTS or .sbtopts?

我在文章、博客和 SO 答案中都看到过,但不清楚我应该在我的项目中使用哪个?

答案在help command

  # jvm options and output control
  JAVA_OPTS           environment variable, if unset uses "$default_java_opts"
  .jvmopts            if this file exists in the current directory, its contents
                      are appended to JAVA_OPTS
  SBT_OPTS            environment variable, if unset uses "$default_sbt_opts"
  .sbtopts            if this file exists in the current directory, its contents
                      are prepended to the runner args
  /etc/sbt/sbtopts    if this file exists, it is prepended to the runner args
  -Dkey=val           pass -Dkey=val directly to the java runtime
  -J-X                pass option -X directly to the java runtime
                      (-J is stripped)
  -S-X                add -X to sbt's scalacOptions (-S is stripped)
In the case of duplicated or conflicting options, the order above
shows precedence: JAVA_OPTS lowest, command line options highest.

由于列表中较低的选项具有较高的优先级,我们可以假设 .sbtopts 优先于 SBT_OPTS。这是有道理的,因为您可以在 .bashrc 中设置 SBT_OPTS 并且应该有一种方法可以自动覆盖 .sbtopts 提供的每个项目。