Skip to content

Commit 3a4c98a

Browse files
authored
chore: mark scala-library and scalajs-scalalib_2.13 as always instead of semver-spec (#23753)
In some scenarios, specifically in cross compilation projects, sbt will complain that `scala-library:2.13.x` and `scala-library:3.x.y` might be imcompatible, as they are both declared `semver-spec`. See en example here: ```scala [error] (update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible: [error] [error] * org.scala-lang:scala-library:3.8.0-RC1-bin-SNAPSHOT (semver-spec) is selected over 2.13.0 [error] +- org.scala-lang:scala3-library_3:3.8.0-RC1-bin-SNAPSHOT (depends on 3.8.0-RC1-bin-SNAPSHOT) [error] +- org.scala-lang.modules:scala-xml_2.13:1.2.0 (depends on 2.13.0) ``` In this PR, we change the version scheme of both `scala-library` and `scalajs-scalalib_2.13` to `always` so that the transition between the old stdlib structure and the new one stay invisible to the users. In the future, when we break binary compatibility (meaning Scala 4), we can revert this PR and have artifacts labeled with `semver-spec` as it will be exactly that scheme. --- The correctness was validated in #23748 locally. [skip ci]
2 parents c535dbc + aff013e commit 3a4c98a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

project/Build.scala

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,12 @@ object Build {
16611661
name := "scala-library-nonbootstrapped",
16621662
moduleName := "scala-library",
16631663
version := dottyNonBootstrappedVersion,
1664-
versionScheme := Some("semver-spec"),
1664+
// We mark the current library as "always" instead of "semver-spec" so that buildtools can
1665+
// assume binary compatibility between 2.13.x and 3.x.y. If not set, build tools will, at least sbt,
1666+
// will error by claiming that scala-library:2.13.x and 3.x.y are potentially binary incompatible.
1667+
// Situation where we have 2.13.x and 3.x.y in the same dependency tree happens
1668+
// because we allow cross-compilation.
1669+
versionScheme := Some("always"),
16651670
scalaVersion := referenceVersion, // nonbootstrapped artifacts are compiled with the reference compiler (already officially published)
16661671
crossPaths := false, // org.scala-lang:scala-library doesn't have a crosspath
16671672
autoScalaLibrary := false, // do not add a dependency to stdlib
@@ -1736,7 +1741,12 @@ object Build {
17361741
name := "scala-library-bootstrapped",
17371742
moduleName := "scala-library",
17381743
version := dottyVersion,
1739-
versionScheme := Some("semver-spec"),
1744+
// We mark the current library as "always" instead of "semver-spec" so that buildtools can
1745+
// assume binary compatibility between 2.13.x and 3.x.y. If not set, build tools will, at least sbt,
1746+
// will error by claiming that scala-library:2.13.x and 3.x.y are potentially binary incompatible.
1747+
// Situation where we have 2.13.x and 3.x.y in the same dependency tree happens
1748+
// because we allow cross-compilation.
1749+
versionScheme := Some("always"),
17401750
// sbt defaults to scala 2.12.x and metals will report issues as it doesn't consider the project a scala 3 project
17411751
// (not the actual version we use to compile the project)
17421752
scalaVersion := referenceVersion,
@@ -1851,7 +1861,12 @@ object Build {
18511861
// Yes, I know, this is weird and feels wrong.
18521862
moduleName := "scalajs-scalalib_2.13",
18531863
version := dottyVersion,
1854-
versionScheme := Some("semver-spec"),
1864+
// We mark the current library as "always" instead of "semver-spec" so that buildtools can
1865+
// assume binary compatibility between 2.13.x and 3.x.y. If not set, build tools will, at least sbt,
1866+
// will error by claiming that scalajs-scalalib_2.13:2.13.x and 3.x.y are potentially binary incompatible.
1867+
// Situation where we have 2.13.x and 3.x.y in the same dependency tree happens
1868+
// because we allow cross-compilation.
1869+
versionScheme := Some("always"),
18551870
crossPaths := false,
18561871
// sbt defaults to scala 2.12.x and metals will report issues as it doesn't consider the project a scala 3 project
18571872
// (not the actual version we use to compile the project)

0 commit comments

Comments
 (0)