Skip to content

[2.x] dependencyMode #8942

@eed3si9n

Description

@eed3si9n

This is a feature request proposed by soc, similar to the feature available on Bazel's rules_scala - https://github.com/bazel-contrib/rules_scala/blob/master/docs/dependency-tracking.md and https://github.com/cb372/sbt-explicit-dependencies.

Step 1

A new setting called dependencyMode.

scalaVersion := "3.8.1"
// implicitly libraryDependencies also includes the standard library
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.7.0"
dependencyMode := DependencyMode.direct

Expectations 1

When dependencyMode is set to DependencyMode.direct, Compile / externalClasspath includes only the direct dependencies of libraryDependencies and the transitive scala-library:

  1. org.typelevel:cats-effect_3:3.7.0
  2. org.scala-lang:scala3-library_3:3.8.1
  3. org.scala-lang:scala-library_3:3.8.1

Same for Test / externalClasspath. This means using classes from Cats Core should result in an compilation error.

Step 2

scalaVersion := "3.8.1"
// implicitly libraryDependencies also includes the standard library
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.7.0"
dependencyMode := DependencyMode.plusOne

Expectations 2

When dependencyMode is set to DependencyMode.plusOne, Compile / externalClasspath includes the transitive dependencies of libraryDependencies at depth 2 (direct plus one) and the transitive scala-library:

  1. org.typelevel:cats-effect_3:3.7.0
  2. org.typelevel:cats-effect-kernel_3:3.7.0
  3. org.typelevel:cats-effect-std_3:3.7.0
  4. org.typelevel:cats-mtl_3:1.6.0
  5. org.scala-lang:scala3-library_3:3.8.1
  6. org.scala-lang:scala-library_3:3.8.1

Same for Test / externalClasspath. This means using classes from Cats Core should result in an compilation error.

Step 3

// This is the default value
dependencyMode := DependencyMode.transitive

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions