Skip to content

[2.x] fix: Handle JVM parameters with spaces in dot files#8730

Merged
eed3si9n merged 3 commits intosbt:developfrom
Eruis2579:fix/7333-sbtopts-spaces
Feb 14, 2026
Merged

[2.x] fix: Handle JVM parameters with spaces in dot files#8730
eed3si9n merged 3 commits intosbt:developfrom
Eruis2579:fix/7333-sbtopts-spaces

Conversation

@Eruis2579
Copy link
Copy Markdown
Contributor

@Eruis2579 Eruis2579 commented Feb 11, 2026

Fixes #7333

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.

Solution

Parsing was updated to be quote-aware. A new parseLineIntoWords() helper splits lines while respecting single and double quotes. loadConfigFileIntoArray() loads config files into bash arrays: for -J lines it splits the remainder and prepends -J to each token (e.g. -J--add-modules jdk.incubator.concurrent-J--add-modules and -Jjdk.incubator.concurrent); for other lines it uses quote-aware splitting. .sbtopts now uses loadConfigFileIntoArray instead of loadConfigFile; .jvmopts uses loadConfigFileIntoArray and merges the result into java_args instead of appending via JAVA_OPTS string concatenation.

Testing

Two integration tests were added in RunnerScriptTest.scala: one for -J--add-modules jdk.incubator.concurrent in .sbtopts, and one for -Dtest.7333="value with spaces" in .jvmopts, both verifying that the full values are passed correctly to the JVM.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sbtopts does not recognize JVM parameters with spaces

2 participants