147 Commits
Author SHA1 Message Date
Matthias KurzandClaude Opus 5.5 121bab88bb [2.x] fix: Forward -J options to sbt server (#9839)
**Problem**
The native thin client discards -J JVM options before it starts the
server, so sbt -J-Xmx2G starts the server with the runner's default
1 GB heap. sbt.bat does not handle -J on the command line: it passes
the option to sbt as a command, which exits with "Not a valid
command". Its default memory check also misses heap options given on
the command line or as -XX:MaxRAM and RAM percentages, so the
appended -Xmx1024m overrides them.

**Solution**
sbtn passes -J options to the server script, and strips -J when it
starts the launcher JAR through java. A -J split out of a quoted
command stays in that command, and a bare -J is dropped. sbt.bat
strips -J, adds the option to the JVM options, rejoins -J-D and -J-XX
values that cmd.exe splits at '=', and passes -J options on to sbtn.
Its default memory check ignores quotes and checks the same options
as the Unix runner.

Generated-by: OpenAI Codex
Generated-by: Claude Code

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-28 16:51:34 -04:00
Anatolii Kmetiuk 79c7d9d728 [2.x] fix: Honor JAVA_HOME in the Unix launcher (#9825)
Problem: The Unix launcher ignores JAVA_HOME and selects Java from PATH when JAVACMD is absent.

Solution: Check JAVA_HOME/bin/java before falling back to PATH while preserving explicit --java-home and JAVACMD precedence.

Fixes #9794
2026-09-25 14:30:25 -04:00
Stas Shevchenko c623288a9a [2.x] fix: Fixes Windows runner handling of sbt bsp (#9766)
* fix: forward bsp argument to sbt on Windows
* test: exercise sbt script bsp command directly
2026-09-14 14:34:04 -04:00
Eugene Yokota f9688c1464 Apply Scalafmt format (Scala 3 syntax) 2026-09-10 14:16:27 -04:00
Stas Shevchenko d4507648a5 fix: keep every output line the runner test reads (#9687) 2026-09-04 16:56:35 +09:00
Viktor Rudebeck 8c12215925 [2.x] Remove global.base setting in windows runner script (#9688)
This is essentially applying the same fix as in #8795 but for the Windows sbt.bat script. 
We now only set -Dsbt.global.base when explicitly asked for with the --sbt-dir option.
2026-08-29 00:19:11 -05:00
eugene yokota 3d95e91b5f [2.x] fix: Fixes Windows runner (#9680)
**Problem**
1. On Windows, sbt.bat re-parses its own already-received arguments a second time internally, via call/goto with an unquoted variable splice (call :run !SBT_ARGS!, and similarly for -D/-XX flags, several _SBT_OPTS-sourced flags, and the native-client dispatch path). That extra re-tokenization could let &, |, (, or ) inside an argument escape their quoting and run as separate shell commands.
2. The -D/-XX/-- argument handling spliced the raw argument value into a for /F ... in ("%g%") do ( ... ) construct nested up to four levels deep inside multi-line if blocks. Apparently, that confuses cmd to miscount the parentheses.

**Solution**
1. Call :run without the argument.
2. Avoid for /F
2026-08-26 13:53:25 -04:00
Anatolii Kmetiuk 893e22102b [2.x] fix: Fixes -V parsing in sbt runners (#9626)
Problem: -V is consumed by the launcher instead of sbt in sbt tasks -V.

Solution: in the parser's -V behavior, lookback to see if there are commands going before it, in which case, forward -V to sbt.
2026-08-19 13:25:00 -04:00
Jozef Koval 5da646f977 [2.x] fix: Honor -java-home in the Windows launchers (#9434)
**Problem**

-java-home wasn't fully honored on Windows: sbtw rejected the single-dash form, silently ignored bad paths, and didn't propagate the JDK to the sbt/sbtn child; sbt.bat didn't fix up PATH/JAVACMD, and a project .java-version could override an explicit -java-home. Residual #963 gaps (the original javac-from-PATH bug was fixed long ago).

**Solution**

New SelectedJava seam in sbtw resolves the JDK once (--java-home > JAVACMD > JAVA_HOME > PATH) and applies one env overlay on every launch path; sbt.bat's handler now sets PATH/JAVACMD and a one-hop marker so .java-version defers to an explicit -java-home.

JDK_HOME > JAVA_HOME (the issue's "even more desired" ordering) is intentionally **not** implemented — it only mattered when JAVA_HOME pointed at a JRE without javac, and JDK 17+ (required by sbt 2.x) no longer ships standalone JREs, so JAVA_HOME always resolves to a full JDK.
2026-08-13 13:52:46 -04:00
Fabrizio Colonna d95b50d8e0 [2.x] fix: sbt.bat fails to start client/server mode on Windows (#9520)
sbt.bat fails to start in client/server mode on Windows, falling back to running the full JVM in the foreground.

sbtn uses CreateProcess to spawn the server process. The original %%20 path encoding doesn't work in batch delayed expansion context, and the default install path C:\Program Files (x86) contains spaces that CreateProcess splits at.
2026-07-27 19:58:39 -04:00
kenji yoshida e1f118743c [2.x] ci: Build sbt/sbt using sbt 2 (#9244) 2026-07-20 12:38:53 -04:00
kenji yoshida 868f59c33c [2.x] ci: Remove unused code in launcher-package/build.sbt (#9480) 2026-07-20 11:56:38 -04:00
Anatolii Kmetiuk da1a94bea9 [2.x] Add native client startup diagnostics regression test (#9447)
Add native client startup diagnostics regression test
2026-07-14 18:27:28 -04:00
eugene yokota 69fa196803 [2.x] fix: Fixes sbt runner openbsd support (#9394)
**Problem**
sbt runner script defaults to sbtn, even on the operating system
where sbtn is not available.

**Solution**
This fallbacks to the jvm client.
2026-06-28 15:30:54 -04:00
Anatolii Kmetiuk 4766e4370d [2.x] fix: Fixes runner parsing build.properties with whitespaces (#9374)
Problem
When build.properties contains whitespaces like sbt.version = 1.12.12, parsing fails and the detected sbt version falls back to 2.0.0.

Solution
Trim whitespaces in build.properties.
2026-06-25 02:48:40 -04:00
kenji yoshida f3d1090350 [2.x] test: Update sbt.version in launcher-package/citest2 (#9357) 2026-06-19 22:11:30 -04:00
eugene yokota b9e98b9e8a [2.x] Update to Scala 3.8.4 (#9302) 2026-06-07 20:52:13 -04:00
kenji yoshida 536e676481 [2.x] refactor: format launcherPackageIntegrationTest (#9245) 2026-05-18 14:41:52 -04:00
eugene yokota 46f0b89642 [2.x] Add runner support for execution log (#9237)
**Problem/Solution**
This adds runner commandline option experimental_execution_log.
2026-05-17 03:01:12 -04:00
kenji yoshida 6b39acc892 [2.x] ci: Fix warnings in launcherPackage sub project (#9188) 2026-05-05 00:18:16 -04:00
eugene yokota 63d5a1103b [2.x] Improve --help (#9180)
**Problem**
Some runner options are not documented in --help.

**Solution**
Fix it.
2026-05-03 21:24:16 -04:00
kenji yoshida 2dbc85ffcf [2.x] ci: Avoid deprecated replaceAllLiterally (#9173)
- https://github.com/scala/scala3/commit/b4aa12d2b04ee02f871ff973a21903184a1fce99
- https://github.com/scala/scala/blob/v2.12.21/src/library/scala/collection/immutable/StringLike.scala#L177-L184
- https://github.com/scala/scala3/blob/3.8.2/library/src/scala/collection/StringOps.scala#L746-L747
2026-05-03 12:40:44 -04:00
kenji yoshida 590dbbacb8 Avoid infix syntax in build files (#9175) 2026-05-03 12:40:00 -04:00
kenji yoshida c9c90978e4 [2.x] ci: Avoid postfix in build files (#9150) 2026-04-29 03:13:17 -04:00
jimcody1995 0f2c973452 [2.x] fix: Avoid dependencyTree browse crashes on Linux (#9147)
**Problem**
`dependencyTree` with `--browse` can throw when desktop browse is unavailable (for example on Wayland/headless environments), causing command failure.

**Solution**
Handle unsupported desktop/browse actions and runtime browse failures gracefully by logging a warning instead of throwing, and add regression tests for unsupported/throwing desktop scenarios.

Generated-by: Cursor Codex 5.3
2026-04-27 22:12:14 -04:00
eugene yokota 5b9553af9e [2.x] Bump sbtn to 2.0.0-RC13 (#9140) 2026-04-27 01:03:42 -04:00
kenji yoshida 4e4ab9f464 [2.x] Update sbt version in launcher-package test (#9021) 2026-04-05 19:26:05 -04:00
kenji yoshida 8ad6ada60f [2.x] Scala 3.8.3 (#8997) 2026-04-05 14:28:47 -04:00
kenji yoshida 6d44aca9b1 Add parentheses (#9000) 2026-03-31 13:48:59 -04:00
BitToby be305eb3a5 fix: Use sbt script in BSP config instead of hardcoded Java path (#8920)
**Problem**

sbt bspConfig writes the absolute path of the current Java binary into .bsp/sbt.json. When the user switches Java versions (via sdkman, cs java, etc.) or removes that JDK, the IDE fails to start the sbt BSP server because the hardcoded path is stale or gone.

**Solution**

When an sbt launcher script is available (via `sbt.script` system property or PATH lookup), generate:

"argv": ["/path/to/sbt", "bsp"]
2026-03-19 20:57:53 -04:00
kenji yoshida 5dad0d325f Format launcher-package/build.sbt (#8898) 2026-03-11 20:11:02 -04:00
kenji yoshida 5fb9f3c5fa [2.x] refactor: Use InputStream.transferTo (#8896)
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/InputStream.html#transferTo(java.io.OutputStream)
2026-03-11 14:32:40 -04:00
PandaMan 1ab9411446 [2.x] Improve -help/--help and fix launcher test harness (#8879)
- sbt script: add 'Getting started' section to usage (create project, help commands)
- sbt script: handle -h/--help without starting JVM, exit 0
2026-03-09 23:11:05 -04:00
PandaMan 119aa4d1a7 [2.x] fix: handle -sbt-dir with spaces from .sbtopts (#8875)
**Problem**

When you pass -sbt-dir "/Users/a' dog" on the command line, the launcher correctly produces:

-Dsbt.global.base=/Users/a' dog

But when you put the same option into .sbtopts, the launcher previously split the line on spaces without respecting quotes, so the resulting -Dsbt.global.base was truncated (for example, -Dsbt.global.base=/Users/a'). This made .sbtopts behavior inconsistent with CLI behavior and broke setups where the global sbt directory path contains spaces and an embedded quote.
2026-03-05 00:41:30 -05:00
eugene yokota 2d18eadd2c [2.x] Comments in dot files (#8841)
**Problem**
Hash comments doesn't work in dot files.

**Solution**
This reapplies the comment removal sed,
with improved inline comment handling.
2026-03-01 02:54:12 -05:00
kenji yoshida f64b5288ca [2.x] ci: Update launcher-package rpmUrl (#8833) 2026-02-28 12:48:26 -05:00
bitloi 58f34117ca [2.x] perf: short-circuit --version from build.properties (#8822)
Avoid launching sbt just to render --version by reading sbt.version directly from project/build.properties in the shell script, batch script, and sbtw wrapper. Tighten launcher integration assertions to verify version output no longer depends on the sbtVersion command output.
2026-02-27 12:02:17 -05:00
Dream 28d877f633 [2.x] fix: Runner should fail on JDK < 17 for sbt 2.x (#8825)
**Problem**
Running sbt 2.x with JDK 8 produces a confusing "server was not
detected" error because the JDK version check only required JDK 8+
and only ran in the non-native-client path.

**Solution**
Move java_version detection before the native client decision and add
checkJava17ForSbt2 that requires JDK 17+ when sbt major version >= 2.

Fixes #8813

* [2.x] fix: Fail early when sbt 2.x is run with JDK < 17 (sbtw)

Move JDK version check before native client decision in sbtw and
require JDK 17+ when build.properties declares sbt 2.x.

* [2.x] fix: Fail early when sbt 2.x is run with JDK < 17 (sbt.bat)

Move checkjava before native client decision in sbt.bat and require
JDK 17+ when build.properties declares sbt 2.x.

* [2.x] test: Add minimumJdkVersion helper and unit tests for sbtw

Extract JDK version check logic into Runner.minimumJdkVersion for
testability. Add RunnerSpec with tests for sbt 1.x, 2.x, and 3.x
version detection.

* [2.x] test: Bump fake java to JDK 17 for integration tests

The fake java script used by launcher integration tests reported
JDK 8. Since sbt 2.x now requires JDK 17+, the citest2 (sbt 2.x)
integration tests would fail with the new JDK version check.

* Simulate JDK 9+ rt.jar handling in fake java script

Instead of silently ignoring --rt-ext-dir (which causes sbt.bat
to mkdir on an empty string), properly simulate JDK 9+ behavior
by creating a temp directory with java9-rt-ext- prefix and a
dummy rt.jar inside it.
2026-02-27 11:43:24 -05:00
eugene yokota 32c5637dc9 [2.x] test: Add Git Bash test on Windows (#8779) 2026-02-25 22:51:52 -05:00
kenji yoshida f976330759 Scala 3.8.2 (#8805) 2026-02-24 00:29:44 -05:00
eugene yokota 4b3c525c22 Revert "[2.x] fix: Handle JVM parameters with spaces in dot files (#8730)" (#8797)
This reverts commit 921efce541.
Ref https://github.com/sbt/sbt/issues/8767

**Problem**
On Git Bash on Windows, we get a cryptic error Invalid maximum heap size: -Xmx2G.

**Solution**
Revert.
2026-02-23 02:41:29 -05:00
eugene yokota 0eff5369d9 [2.x] fix: Remove global.base setting in runner script (#8795)
**Problem**
1. It's difficult to find out when Process fails.
2. global.base setting isn't needed in sbt runner script.

**Solution**
1. Forward to stderr as it happens.
2. Remove global.base setting in the runner script.
2026-02-23 01:39:15 -05:00
bitloi c6f67d706f [2.x] feat: XDG directory standard (#8769)
- Add SysProp.defaultGlobalBaseDirectory: uses SBT_CONFIG_HOME,
  XDG_CONFIG_HOME/sbt (Unix), LOCALAPPDATA/sbt (Windows), else ~/.sbt
- BuildPaths.defaultGlobalBase delegates to SysProp for consistent default
- sbt script: inject -Dsbt.global.base from XDG when not already set;
  getPreloaded() fallback uses SBT_CONFIG_HOME/XDG_CONFIG_HOME
- sbt.bat: use LOCALAPPDATA/sbt when --sbt-dir not set
- Tests: BuildPathsTest (property + absolute path), RunnerScriptTest (XDG)
2026-02-20 23:32:48 -05:00
Lazz 02d9d4c699 [2.x] fix: Support inline comments in .jvmopts and .sbtopts files (#8758)
**Problem**
After PR #8730 (commit 921efce), inline comments in .jvmopts and .sbtopts files cause errors.
For example, `--add-opens=java.base/java.util=ALL-UNNAMED # comment` results in:
Error: Could not find or load main class #

The # and everything after it is now parsed as separate arguments instead of being stripped as a comment.

**Solution**
Update the sed command in outputConfigFileTokens() to strip inline comments (everything from # to end of line) before parsing tokens.

The new s/\s*\#.*// pattern matches optional whitespace + # + rest of line and removes it.

Generated-by: Claude Sonnet 4.5
2026-02-17 14:42:16 -05:00
bitloi f870b60b7c [2.x] feat: sbtw launcher (#8742)
- Add sbtwProj: Scala 3.x launcher with scopt, drop-in for sbt.bat
- Config: .sbtopts, .jvmopts, sbtconfig.txt, JAVA_OPTS/SBT_OPTS precedence
- Options: --client, --server, --jvm-client, mem, sbt-version, java-home, etc.
- sbt 2.x defaults to native client; --server forces JVM launcher
- JVM run via xsbt.boot.Boot; native via sbtn with --sbt-script
- build.sbt: sbtwProj in root build and allProjects; NativeImagePlugin
- Fixes: JAVA_OPTS then .jvmopts, build.properties trim, shutdownAll PID, Iterator.lastOption
2026-02-16 16:21:30 -05:00
PandaMan 921efce541 [2.x] fix: Handle JVM parameters with spaces in dot files (#8730)
**Problem**

The sbt launcher script used naive word splitting when parsing `.sbtopts` and `.jvmopts`, so arguments with spaces were split incorrectly. For example, `-J--add-modules jdk.incubator.concurrent` in `.sbtopts` and `-Dtest.key="value with spaces"` in `.jvmopts` were not passed to the JVM as intended.
2026-02-14 03:17:44 -05:00
Pluto 0cae58403f [2.x] fix: handle --version in sbt 2.x project dirs (sbt#8717) (#8735)
**Problem**
`sbt --version` in sbt 2.x project directories was delegated to the native client, which could try to start/connect to a server instead of printing version info.

**Solution**
Skip native-client delegation when `--version` is requested, and add runner-script tests for sbt 1.x and 2.x project variants.
2026-02-13 09:10:51 -08:00
PandaMan de2c27abeb [2.x] fix: handle --script-version sbt 2.x project dirs (#8715)
When in an sbt 2.x project directory, the script used to delegate to sbtn
before checking --script-version, so 'sbt --script-version' ran sbtn and
failed. Now we print the script version and exit before the native client
branch.
2026-02-07 22:16:21 -05:00
eugene yokota 499ec520a7 [2.x] require coreutils for RPM (#8712)
**Problem**
Apparently sbt can fail when it doesn't have rm,
which can happen "when building relocatable RPM's and building an OS image in a chroot."

**Solution**
It was suggested that we require coreutils.
2026-02-07 17:23:39 -05:00
Pluto 12deebba2b [2.x] fix: restore CLI precedence over .sbtopts
According to the issue, `.sbtopts` entries are appended after
CLI args in sbt 1.12.x, so `.sbtopts` JVM memory settings (e.g., `-Xmx2g`) override CLI `--mem`,
causing invalid JVM settings.
2026-02-05 18:04:55 -05:00