From e756c6dc88e84475f73108511a23894417362f9e Mon Sep 17 00:00:00 2001 From: MkDev11 Date: Tue, 13 Jan 2026 05:18:05 -0500 Subject: [PATCH 1/3] [2.x] fix: Skip native client for sbt new/init commands (#8512) Fixes #7497 --- launcher-package/src/universal/bin/sbt.bat | 5 +++++ sbt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/launcher-package/src/universal/bin/sbt.bat b/launcher-package/src/universal/bin/sbt.bat index 3a876b758..f30e34572 100755 --- a/launcher-package/src/universal/bin/sbt.bat +++ b/launcher-package/src/universal/bin/sbt.bat @@ -926,6 +926,11 @@ for /f "delims=.-_ tokens=1-2" %%v in ("!JAVA_VERSION!") do ( rem parse the first two segments of sbt.version and set run_native_client to rem 1 if the user has also indicated they want to use native client. +rem sbt new/init should not use native client as it needs to run outside a project +if defined sbt_new ( + set run_native_client= + exit /B 0 +) set sbtV=!build_props_sbt_version! set sbtBinaryV_1= set sbtBinaryV_2= diff --git a/sbt b/sbt index c1944ce7d..4cccc6650 100755 --- a/sbt +++ b/sbt @@ -802,6 +802,11 @@ detectNativeClient() { # Run native client if build.properties points to 1.4+ and has SBT_NATIVE_CLIENT isRunNativeClient() { + # sbt new/init should not use native client as it needs to run outside a project + if [[ "$sbt_new" == "true" ]]; then + echo "false" + return + fi sbtV="$build_props_sbt_version" [[ "$sbtV" == "" ]] && sbtV="$init_sbt_version" [[ "$sbtV" == "" ]] && sbtV="0.0.0" From c50f5b7fd1878a53d2c0bb72296689632699c0f5 Mon Sep 17 00:00:00 2001 From: MkDev11 Date: Tue, 13 Jan 2026 05:19:19 -0500 Subject: [PATCH 2/3] [2.x] fix: Fix sbt new argument parsing on Windows (#8509) Only recombine split -- arguments after new/init command. Fixes #7507 --- launcher-package/src/universal/bin/sbt.bat | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/launcher-package/src/universal/bin/sbt.bat b/launcher-package/src/universal/bin/sbt.bat index f30e34572..123c89f59 100755 --- a/launcher-package/src/universal/bin/sbt.bat +++ b/launcher-package/src/universal/bin/sbt.bat @@ -547,6 +547,21 @@ if not "%g:~0,5%" == "-XX:+" if not "%g:~0,5%" == "-XX:-" if "%g:~0,3%" == "-XX" ) ) +if defined sbt_new if "%g:~0,2%" == "--" ( + rem special handling for -- template arguments since '=' gets parsed away on Windows + for /F "tokens=1 delims==" %%a in ("%g%") do ( + rem make sure it doesn't have the '=' already + if "%g%" == "%%a" ( + if not "%~1" == "" ( + call :dlog [args_loop] -- argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" + shift + goto args_loop + ) + ) + ) +) + rem the %0 (instead of %~0) preserves original argument quoting set SBT_ARGS=!SBT_ARGS! %0 @@ -782,6 +797,18 @@ if not "%p:~0,5%" == "-XX:+" if not "%p:~0,5%" == "-XX:-" if "%p:~0,3%" == "-XX" ) ) +if defined sbt_new if "%p:~0,2%" == "--" ( + rem special handling for -- template arguments since '=' gets parsed away on Windows + for /F "tokens=1 delims==" %%a in ("%p%") do ( + rem make sure it doesn't have the '=' already + if "%p%" == "%%a" if not "%~1" == "" ( + echo %0=%1 + shift + goto echolist + ) + ) +) + if "%p:~0,14%" == "-agentlib:jdwp" ( rem special handling for --jvm-debug since '=' and ',' gets parsed away for /F "tokens=1 delims==" %%a in ("%p%") do ( From b4e384586768ed383a600a0ce0ac086f7f26c283 Mon Sep 17 00:00:00 2001 From: "E.G" <146701565+GlobalStar117@users.noreply.github.com> Date: Sun, 18 Jan 2026 06:29:30 +1100 Subject: [PATCH 3/3] fix: Handle -X JVM options on command line (fixes #5742) (#8566) Previously, passing JVM options like -Xmx1G directly on the command line would result in an error: sbt -v -Xmx1G [error] Expected ';' [error] -Xmx1G [error] ^ This was because -X options were being passed to sbt as commands instead of being recognized as JVM arguments. Changes: - Added handling for -X options in sbt.bat to pass them to the JVM - Updated help text to document this feature - Added integration tests for the new functionality --- .../src/test/scala/RunnerMemoryScriptTest.scala | 9 +++++++++ launcher-package/src/universal/bin/sbt.bat | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/launcher-package/integration-test/src/test/scala/RunnerMemoryScriptTest.scala b/launcher-package/integration-test/src/test/scala/RunnerMemoryScriptTest.scala index 3978c4fb3..7f2c3ffd0 100644 --- a/launcher-package/integration-test/src/test/scala/RunnerMemoryScriptTest.scala +++ b/launcher-package/integration-test/src/test/scala/RunnerMemoryScriptTest.scala @@ -74,4 +74,13 @@ object RunnerMemoryScriptTest extends verify.BasicTestSuite with ShellScriptUtil assert(out.contains[String]("-Xms111m")) assert(out.contains[String]("-Xss12m")) + // Test for issue #5742: -X options passed directly on command line + testOutput("sbt -Xmx1G directly on command line")("-Xmx1G", "-v"): (out: List[String]) => + assert(out.contains[String]("-Xmx1G")) + + testOutput("sbt -Xms512M -Xmx1G directly on command line")("-Xms512M", "-Xmx1G", "-v"): + (out: List[String]) => + assert(out.contains[String]("-Xms512M")) + assert(out.contains[String]("-Xmx1G")) + end RunnerMemoryScriptTest diff --git a/launcher-package/src/universal/bin/sbt.bat b/launcher-package/src/universal/bin/sbt.bat index 123c89f59..46a495778 100755 --- a/launcher-package/src/universal/bin/sbt.bat +++ b/launcher-package/src/universal/bin/sbt.bat @@ -547,6 +547,13 @@ if not "%g:~0,5%" == "-XX:+" if not "%g:~0,5%" == "-XX:-" if "%g:~0,3%" == "-XX" ) ) +rem handle -X JVM options (e.g., -Xmx1G, -Xms512M, -Xss4M) - fixes #5742 +if "%g:~0,2%" == "-X" ( + call :dlog [args_loop] -X JVM argument %~0 + call :addJava %~0 + goto args_loop +) + if defined sbt_new if "%g:~0,2%" == "--" ( rem special handling for -- template arguments since '=' gets parsed away on Windows for /F "tokens=1 delims==" %%a in ("%g%") do ( @@ -1096,6 +1103,8 @@ echo are prepended to the runner args echo !SBT_CONFIG! echo if this file exists, it is prepended to the runner args echo -Dkey=val pass -Dkey=val directly to the java runtime +echo -X^ pass -X^ directly to the java runtime +echo ^(e.g., -Xmx1G, -Xms512M, -Xss4M^) rem echo -J-X pass option -X directly to the java runtime rem echo ^(-J is stripped^) rem echo -S-X add -X to sbt's scalacOptions ^(-S is stripped^)