From 45badebcee9f33f8792144d2bf6048c2d1313347 Mon Sep 17 00:00:00 2001 From: Sam Halliday Date: Wed, 24 Aug 2016 21:57:06 +0100 Subject: [PATCH 1/2] add support for .jvmopts to the bash launcher --- src/linux/usr/share/man/man1/sbt.1 | 9 +++++++-- src/universal/bin/sbt | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/linux/usr/share/man/man1/sbt.1 b/src/linux/usr/share/man/man1/sbt.1 index 27772cbdc..6dc5d7211 100644 --- a/src/linux/usr/share/man/man1/sbt.1 +++ b/src/linux/usr/share/man/man1/sbt.1 @@ -72,10 +72,15 @@ add -X to sbt's scalacOptions (-S is stripped) .RS The user configuration file. .RE +.I ".jvmopts" +.RS +if this file exists in the current directory, its contents are appended +to the JAVA_OPTS. +.RE .I ".sbtopts" .RS -if this file exists in the current directory, it is prepended to the -runner args. +if this file exists in the current directory, its contents are prepended +to the runner args. .RE .I "/etc/sbt/sbtopts" .RS diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 632d45fd5..d622f98ef 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -94,9 +94,11 @@ Usage: $script_name [options] # jvm options and output control JAVA_OPTS environment variable, if unset uses "$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, it is - prepended to the runner args + .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 @@ -137,16 +139,14 @@ loadConfigFile() { done } -# TODO - Pull in config based on operating system... (MSYS + cygwin should pull in txt file). # Here we pull in the global settings configuration. [[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" -# -- Windows behavior stub'd -# JAVA_OPTS=$(cat "$WDIR/sbtconfig.txt" | sed -e 's/\r//g' -e 's/^#.*$//g' | sed ':a;N;$!ba;s/\n/ /g') - # Pull in the project-level config file, if it exists. [[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@" +# Pull in the project-level java config, if it exists. +[[ -f ".jvmopts" ]] && export JAVA_OPTS="$JAVA_OPTS $(loadConfigFile .jvmopts)" run "$@" From d9da67979a6498cf8383dbe7fa2d76461b7009eb Mon Sep 17 00:00:00 2001 From: Sam Halliday Date: Thu, 25 Aug 2016 20:06:23 +0100 Subject: [PATCH 2/2] -java-home should set PATH for javac usage --- src/universal/bin/sbt-launch-lib.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 62889cd4a..78732874b 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -128,7 +128,12 @@ process_args () { -sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;; -sbt-version) require_arg version "$1" "$2" && sbt_version="$2" && shift 2 ;; - -java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;; + -java-home) require_arg path "$1" "$2" && + java_cmd="$2/bin/java" && + export JAVA_HOME="$2" && + export JDK_HOME="$2" && + export PATH="$2/bin:$PATH" && + shift 2 ;; -D*) addJava "$1" && shift ;; -J*) addJava "${1:2}" && shift ;;