Skip to content

[2.0.x] bport: Add dependencyMode setting to control classpath transitivity#8972

Merged
eed3si9n merged 1 commit intosbt:2.0.xfrom
eed3si9n:bport/dependency-mode
Mar 24, 2026
Merged

[2.0.x] bport: Add dependencyMode setting to control classpath transitivity#8972
eed3si9n merged 1 commit intosbt:2.0.xfrom
eed3si9n:bport/dependency-mode

Conversation

@eed3si9n
Copy link
Copy Markdown
Member

This is a 2.0.x backport of #8960

Problem
sbt always includes all transitive dependencies on the classpath. This makes it easy to accidentally depend on transitive dependencies without declaring them, leading to fragile builds that break when a library changes its own dependencies.

Solution
Add a dependencyMode setting with three modes:

  • DependencyMode.Transitive (default) — current behavior, all transitive dependencies on the classpath
  • DependencyMode.Direct — only declared dependencies plus scala-library on the classpath
  • DependencyMode.PlusOne — declared dependencies plus their immediate transitive dependencies plus scala-library

Fixes #8942

…ity (sbt#8960)

**Problem**
sbt always includes all transitive dependencies on the classpath.
This makes it easy to accidentally depend on transitive dependencies
without declaring them, leading to fragile builds that break when
a library changes its own dependencies.

**Solution**
Add a `dependencyMode` setting with three modes:

- DependencyMode.Transitive (default) — current behavior, all
  transitive dependencies on the classpath
- DependencyMode.Direct — only declared dependencies plus
  scala-library on the classpath
- DependencyMode.PlusOne — declared dependencies plus their
  immediate transitive dependencies plus scala-library

Fixes sbt#8942
@eed3si9n eed3si9n merged commit 1d77704 into sbt:2.0.x Mar 24, 2026
15 checks passed
@eed3si9n eed3si9n deleted the bport/dependency-mode branch March 24, 2026 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants