-
Notifications
You must be signed in to change notification settings - Fork 1k
[2.x] dependencyMode #8942
Description
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.directExpectations 1
When dependencyMode is set to DependencyMode.direct, Compile / externalClasspath includes only the direct dependencies of libraryDependencies and the transitive scala-library:
- org.typelevel:cats-effect_3:3.7.0
- org.scala-lang:scala3-library_3:3.8.1
- 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.plusOneExpectations 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:
- org.typelevel:cats-effect_3:3.7.0
- org.typelevel:cats-effect-kernel_3:3.7.0
- org.typelevel:cats-effect-std_3:3.7.0
- org.typelevel:cats-mtl_3:1.6.0
- org.scala-lang:scala3-library_3:3.8.1
- 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