diff --git a/src/reference/02-DetailTopics/01-Using-sbt/03-Cross-Build.md b/src/reference/02-DetailTopics/01-Using-sbt/03-Cross-Build.md index 3a5daa13..19bc4c14 100644 --- a/src/reference/02-DetailTopics/01-Using-sbt/03-Cross-Build.md +++ b/src/reference/02-DetailTopics/01-Using-sbt/03-Cross-Build.md @@ -285,6 +285,29 @@ depending on the value of `crossPaths`. Because (unlike Scala library) Scala compiler is not forward compatible among the patch releases, compiler plugins should use `CrossVersion.full`. +#### Scala 3 specific cross-versions + +In a Scala 3 project you can use Scala 2.13 libraries: + +```scala +("a" % "b" % "1.0") cross CrossVersion.for3Use2_13 +``` + +This is equivalent to using `%%` except it resolves the `_2.13` variant +of the library when `scalaVersion` is 3.x.y. + +Conversely we have `CrossVersion.for2_13Use3` to use the `_3` variant of the +library when `scalaVersion` is 2.13.x: + +```scala +("a" % "b" % "1.0") cross CrossVersion.for2_13Use3 +``` + +**Warning for library authors:** It is generally not safe to publish +a Scala 3 library that depends on a Scala 2.13 library or vice-versa. +The reason is to prevent your end users from having two versions `x_2.13` +and `x_3` of the same x library in their classpath. + #### More about using cross-built libraries You can have fine-grained control over the behavior for different Scala versions