[2.x] fix: Support inline comments in .jvmopts and .sbtopts files#8758
Merged
eed3si9n merged 2 commits intosbt:developfrom Feb 17, 2026
Merged
[2.x] fix: Support inline comments in .jvmopts and .sbtopts files#8758eed3si9n merged 2 commits intosbt:developfrom
eed3si9n merged 2 commits intosbt:developfrom
Conversation
**Problem** After PR sbt#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. Changed: sed $'/^\#/d;s/\r$//' To: sed $'/^\#/d;s/\s*\#.*//;s/\r$//' The new s/\s*\#.*// pattern matches optional whitespace + # + rest of line and removes it. **Testing** - Added integration test verifying inline comments are stripped from .jvmopts - Manually tested with .jvmopts containing inline comments - no errors - Full line comments (starting with #) still work correctly Generated-by: Claude Sonnet 4.5
Contributor
Author
You’re welcome! Just signed CLA |
Member
|
I appreciate the details on the PR description. I wish everyone did this. |
Contributor
|
@eed3si9n this PR introduce unexpected deletion, for example: |
Member
|
I guess the expression immediately before |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #8755
Problem
After PR #8730 (commit 921efce), inline comments in
.jvmoptsand.sbtoptsfiles cause errors.For example,
--add-opens=java.base/java.util=ALL-UNNAMED # commentresults in: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:\s*- matches optional whitespace before#\#- matches the#character.*- matches everything to end of lineThis means
--add-opens=java.base/java.util=ALL-UNNAMED # commentbecomes--add-opens=java.base/java.util=ALL-UNNAMEDbefore token parsing.Testing
.jvmopts.jvmoptscontaining inline comments - no errors#) still work correctlyManual test output:
AI Disclosure
Generated-by: Claude Sonnet 4.5
All code has been manually reviewed, tested, and verified to solve issue #8755.