From 4a61c27538affbac3828c2eac7bd24bdc2b3a10b Mon Sep 17 00:00:00 2001 From: Christian Lachner Date: Sun, 30 Jun 2019 14:14:57 +0200 Subject: [PATCH] Add --java-home to sbt.bat In contrast to the unix version of the sbt launcher, the windows version lacks the functionality of specifying JAVA_HOME via launch parameters. This commit adds the missing --java-home parameter to sbt.bat. --- src/universal/bin/sbt.bat | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 78cbe17a2..ac5d33212 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -67,6 +67,9 @@ if "%~1" == "" goto args_end if "%~1" == "-jvm-debug" set JVM_DEBUG=true if "%~1" == "--jvm-debug" set JVM_DEBUG=true +if "%~1" == "-java-home" set SET_JAVA_HOME=true +if "%~1" == "--java-home" set SET_JAVA_HOME=true + if "%JVM_DEBUG%" == "true" ( set /a JVM_DEBUG_PORT=5005 2>nul >nul ) else if "!JVM_DEBUG!" == "true" ( @@ -81,6 +84,24 @@ if "%JVM_DEBUG%" == "true" ( set SBT_ARGS=!SBT_ARGS! %1 ) +if "%SET_JAVA_HOME%" == "true" ( + set SET_JAVA_HOME= + if NOT "%~2" == "" ( + if exist "%~2\bin\java.exe" ( + set _JAVACMD="%~2\bin\java.exe" + set JAVA_HOME="%~2" + set JDK_HOME="%~2" + shift + ) else ( + echo Directory "%~2" for JAVA_HOME is not valid + goto error + ) + ) else ( + echo Second argument for --java-home missing + goto error + ) +) + shift goto args_loop :args_end