Skip to content

Commit

Permalink
Introduce for3Use2_13 and for3_13Use3
Browse files Browse the repository at this point in the history
  • Loading branch information
adpi2 committed Mar 23, 2021
1 parent cff4c87 commit ae01607
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/reference/02-DetailTopics/01-Using-sbt/03-Cross-Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ae01607

Please sign in to comment.