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.
**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.
**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.
Windows CMD interprets parentheses as special syntax for command grouping.
When the project directory path contains parentheses (e.g., in username),
the batch script fails with ') was unexpected at this time.' error.
This fix stores the current directory in a variable using delayed expansion
(!CURRENT_DIR!) instead of using %CD% directly, which properly handles
paths containing parentheses and other special characters.
Fixes#8644
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
Filter rt-ext-dir output for java9-rt-ext- pattern, matching the
Unix script behavior. This prevents debug agent stdout (e.g.,
'Listening for transport dt_socket at address: 1234') from being
incorrectly parsed as a file path.
Fixes#8100
**Problem**
sbt -V tries to show both the sbt version and the runner version,
and ends up creating target directory even on a non-sbt directory.
**Solution**
If the current directory doesn't have a build, just display the runner version.
**Problem**
1. Currently users are automatically opted into -create-sbt,
somewhat implicitly.
2. When somehow they are not, the check mechanism currently blocks for input.
**Solution**
1. Support a new location for sbtopts file under XSG_CONFIG_HOME/sbt
2. Rename -create-sbt to --allow-empty, and don't opt everyone in
3. Exit 1 instead of blocking for input
Fixes#7387
* Fix VM argument passing by .sbtopts file and JAVA_TOOL_OPTIONS environmental variable, improve launcher script integration test setup
* Fix sbt process not exiting in launcher test for --sbt-version
* Fix JAVA_TOOL_OPTIONS in launcher for linux/mac
Fixes#6530
Ref #6101
Problem
-------
Although having sbt server up by default is beneficial to well-tested
platforms like macOS, on less tested setups various native and/or
native-adjacent techniques we use could end up causing instability.
Solution
--------
This adds `--no-server` as a quick way of telling sbt not to start up
the sbt server or create virtual terminal.