This is about to be a significant problem for the Scala ecosystem as a whole. Trying to get ahead of it just a bit…
- Project with
scalaVersion := "0.27.0-RC1"
- Artifact A and artifact B, each of which depend on artifact C. All are cross-published scala libs
- Artifact C has been published for both 0.27.0-RC1 and 2.13
- Artifact A depends on the 2.13 cross-build, while artifact B depends on the Dotty cross-build
I haven’t actually tested this, but I’m relatively certain this turns into an undetected (and thus, unwarned!) transitive dependency conflict. It will ultimately only get resolved at runtime by classpath linearization. This in and of itself sounds benign, and it would be except for the fact that numerous libraries have significant version-specific changes under the hood in order to achieve source-compatibility between Scala 2 and Scala 3.
I honestly think this is something that only sbt can really address. The only option users have is to, first, figure out that they’re in this situation (which requires either staring at dependency graphs, or hitting weird bugs in production and happening to see suspicious things in classpaths), and then they need to add a lot of
excludeAll in a lot of non-obvious places. It gets even more fun if the transitive dependencies on C are to slightly different versions.
Ultimately, I think that sbt needs to detect this kind of situation (where a pair of artifacts would be mutually evictable if they had been published against they same binary version) and, for the special case of 2.13 and any dotty binary version, they should be evicted forward to the Dotty version.