[2.x] fix: Allow ++ command to accept projects not in current state#8505
Merged
eed3si9n merged 1 commit intosbt:developfrom Jan 13, 2026
Merged
Conversation
18986ac to
2c523c3
Compare
…nt state When using '++version project/task', the parser now accepts project/command patterns (e.g., 'docs/docusaurusPublishGhpages') even if the project doesn't exist in the current state. This is achieved by adding a fallback parser that accepts any 'project/command' pattern alongside the combinedParser. Previously, '++2.12.19 docs/task' would fail with 'Project not found' if 'docs' project wasn't available in the current Scala version, but '++2.12.19; docs/task' worked. Now both syntaxes work correctly. The fix is targeted to only accept slash-delimited patterns, avoiding interference with other parser components like the -v verbose flag. Fixes sbt#7574
2c523c3 to
e0c1b17
Compare
Contributor
Author
|
let me know if you have any feedback for me |
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.
Fix: Allow
++command to work with projects that don't exist yetProblem
When you run
sbt '++2.12.19 docs/publishSite', it fails with "Project not found" if thedocsproject only exists after switching to Scala 2.12.19.The workaround has been to use a semicolon to separate commands:
sbt '++2.12.19; docs/publishSite'. This works because the semicolon forces sbt to execute the version switch first, then parse the second command in the new state wheredocsexists.Solution
The parser now accepts
project/taskpatterns even when the project isn't available in the current state. It works like this:state.combinedParser(validates against current project structure)project/taskpattern using a simple slash-delimited parserBy the time the command actually runs, the project exists in the new Scala version's state.
Implementation
Added a
slashCommandfallback parser that matchesproject/taskpatterns:The fix is targeted to only accept slash-delimited patterns, which avoids interfering with other parser components like the
-vverbose flag.Testing
The fix passes the existing
actions/cross-advancedscripted test, which includes various cross-build scenarios with project-scoped commands.Fixes #7574
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=94194147