[2.x] fix: Fixes subproject deps with different Scala versions#8681
Merged
eed3si9n merged 10 commits intosbt:developfrom Feb 3, 2026
Merged
[2.x] fix: Fixes subproject deps with different Scala versions#8681eed3si9n merged 10 commits intosbt:developfrom
eed3si9n merged 10 commits intosbt:developfrom
Conversation
When project baz (e.g. scala 2.13) dependsOn bar (e.g. scala 2.12), resolution was requesting bar_2.13 (dependent's sbv) instead of bar_2.12 (dependency's sbv), so inter-project resolver could not find the artifact. In projectDependenciesTask, for cross-versioned inter-project deps (Binary, Full, For3Use2_13, For2_13Use3), use the dependency project's scala version (depSBV / dep full version) to build a constant cross version so resolution looks up the actual bar_2.12 artifact. - Use sbt.librarymanagement.For3Use2_13/For2_13Use3 in pattern match - Add scripted test dependency-management/i4847-inter-project-variant-scala (bar 2.12, baz 2.13, baz dependsOn bar % Runtime; baz/update and baz/run) Generated-by: Gen-AI
- Remove % Runtime from dependsOn to allow compile-time access to bar - Fix output path to baz/output to match test expectation
Add 'if sbv != depSBV' guard to Binary, Full, For3Use2_13, and For2_13Use3 cases in projectDependenciesTask. When projects share the same Scala version, preserve original behavior to avoid breaking inter-project resolution. Fixes dependency-management/provided-multi test failure.
eed3si9n
reviewed
Feb 3, 2026
Add 'if sbv != depSBV' guard to Binary, Full, For3Use2_13, and For2_13Use3 cases in projectDependenciesTask. When projects share the same Scala version, preserve original behavior exactly to avoid breaking class loader caching. Fixes dependency-management/provided-multi and project/scala-loader tests.
f7dfb3b to
3052b6a
Compare
eed3si9n
reviewed
Feb 3, 2026
dev-miro26
added a commit
to dev-miro26/sbt
that referenced
this pull request
Feb 24, 2026
Per review feedback, move the Scala version mismatch check from compileTask to projectDependenciesTask, where PR sbt#8681 already handles Scala version mixing logic. This provides earlier detection and keeps the validation co-located with cross-version resolution. Generated-by: Copilot
eed3si9n
pushed a commit
that referenced
this pull request
Feb 25, 2026
sbt 2.x allows `dependsOn(...)` between subprojects with mismatched Scala versions without any warning or error. This can lead to confusing classpath issues at compile or runtime, especially now that Scala 3.8+ has dropped backward TASTy compatibility with 2.13. Per review feedback, move the Scala version mismatch check from compileTask to projectDependenciesTask, where PR #8681 already handles Scala version mixing logic. This provides earlier detection and keeps the validation co-located with cross-version resolution. Generated-by: Copilot
eed3si9n
pushed a commit
to eed3si9n/sbt
that referenced
this pull request
Mar 1, 2026
sbt 2.x allows `dependsOn(...)` between subprojects with mismatched Scala versions without any warning or error. This can lead to confusing classpath issues at compile or runtime, especially now that Scala 3.8+ has dropped backward TASTy compatibility with 2.13. Per review feedback, move the Scala version mismatch check from compileTask to projectDependenciesTask, where PR sbt#8681 already handles Scala version mixing logic. This provides earlier detection and keeps the validation co-located with cross-version resolution. Generated-by: Copilot
eed3si9n
added a commit
that referenced
this pull request
Mar 1, 2026
sbt 2.x allows `dependsOn(...)` between subprojects with mismatched Scala versions without any warning or error. This can lead to confusing classpath issues at compile or runtime, especially now that Scala 3.8+ has dropped backward TASTy compatibility with 2.13. Per review feedback, move the Scala version mismatch check from compileTask to projectDependenciesTask, where PR #8681 already handles Scala version mixing logic. This provides earlier detection and keeps the validation co-located with cross-version resolution. Generated-by: Copilot Co-authored-by: dev-miro26 <[email protected]>
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 inter-project dependencies with different Scala versions
When a project depended on another project that was built with a different Scala binary version (e.g. 2.12 vs 2.13), compilation could fail with "not found: value X" because resolution was asking for the wrong artifact.
This change updates how we build the
ModuleIDfor inter-project dependencies inprojectDependenciesTask: we now request the dependency’s Scala binary version (e.g.bar_2.12) instead of the current project’s, so the resolver can find the right artifact. We keep existing behavior forDisabledandConstantcross-version, and add a small safeguard in the default case when the dependency’s Scala version differs from the current project’s.dependency-management/i4847-inter-project-variant-scala— bar (2.12) and baz (2.13), baz depends on bar; verifiesbaz/runsucceeds.dependency-management/provided-multipasses locally (Java 17); if it fails in CI (e.g. on Java 25), that appears to be a pre-existing or environment-specific issue, not caused by this fix.Closes #4847