[2.x] fix: extraProjects with auto-root aggregate breaks key aggregation#8690
Merged
eed3si9n merged 6 commits intosbt:developfrom Feb 5, 2026
Merged
Conversation
…gation When a plugin adds extraProjects, sbt creates an auto root that aggregates all projects but has no plugin tasks (e.g. scripted). The aggregated key parser filtered choices by data.contains(key), so (root, scripted) was rejected and 'scripted' failed with 'No such setting/task'. - Add optional structure param to scopedKeySelected and select - Use isValidForAggregate when structure is present: accept key if it exists in data or aggregates to keys that all exist in data - Pass structure from scopedKeyAggregated/scopedKeyAggregatedFilter so root-scoped keys that exist only on aggregated projects are valid
Contributor
Author
|
@eed3si9n Ready for review! |
eed3si9n
reviewed
Feb 4, 2026
eed3si9n
reviewed
Feb 4, 2026
- scopedKeySelected: structure is required; callers pass None or Some(structure) - select: add two-arg overload for callers without structure; three-arg version has no default so aggregate path is explicit
Contributor
Author
|
Please review again. |
eed3si9n
reviewed
Feb 4, 2026
Member
eed3si9n
left a comment
There was a problem hiding this comment.
Thanks for the contribution. I can't tell from the diff it if fixes the bug or not. As per usual, please include repro test(s), like a scripted test, into the pull request, and declare AI usages if any - https://github.com/sbt/sbt/blob/develop/CONTRIBUTING.md.
…tion) - project/extra-projects-key-aggregate: repro for sbt#4947 Run 'check' at root; without fix: No such setting/task; with fix: runs p/check
2500d40 to
eb89e0e
Compare
Contributor
Author
Done, thanks for the review. |
Key aggregation at root with extraProjects+auto-root aggregate was requiring all aggregated projects to define a task (forall). Change to exists so a task is valid if any aggregated project defines it.
The test for sbt#4947 needs an explicit root that aggregates all projects including z from extraProjects. This validates that check works from root when only defined in subproject p.
eed3si9n
requested changes
Feb 4, 2026
sbt-app/src/sbt-test/project/extra-projects-key-aggregate/build.sbt
Outdated
Show resolved
Hide resolved
When extraProjects adds projects via plugins, the auto-root is created before other projects (defined in build.sbt) are discovered. This caused the auto-root to only aggregate the extraProjects, not all projects. The fix updates processAutoAggregate to add missing projects to the auto-root's aggregation after all projects have been discovered. The fix only applies to auto-generated roots (when hasRoot=false), not to user-defined root projects. Fixes sbt#4947
This was referenced Feb 21, 2026
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.
Closes #4947
What was wrong
When a plugin adds projects via
extraProjects, sbt creates an auto root that aggregates all projects. That root doesn't get plugin tasks (e.g.scriptedfrom SbtPlugin). So if you ranscriptedfrom the shell, you'd get "Not a valid command: scripted" / "No such setting/task" even though a subproject had the task.What we changed
When using the aggregated key parser, a key is now valid if it exists in
datafor that scope or it's an aggregate key and every key it aggregates to exists indata. So(root, scripted)is accepted when the root aggregates a project that definesscripted, and runningscriptedat root runs it on that project as before.Repro test
project/extra-projects-key-aggregateaandp; plugin adds extra projectz→ sbt creates auto root.pdefines the taskcheck.> checkat root; without the fix this fails with "No such setting/task"; with the fix it runsp/checkand passes.AI disclosure
AI usage: I used AI tools (ChatGPT) to assist with this PR: implementation design, code changes, and test setup. The changes were verified locally (compile, lint, unit tests). I have reviewed and understand the code.
mainProj/test).scripted project/extra-projects-key-aggregate(afterpublishLocalBinor in CI).