[2.x] fix: Fix scala-reflect not found problem (#8632)

## Problem
We enforce same-version policy for scala-reflect in Scala 2.13.
However due to sandwich dependency, the graph can bump
scala-library to 3.8.1, which is missing scala-reflect counterpart.

## Solution
Drop the same-version policy.
This commit is contained in:
eugene yokota 2026-01-26 04:55:07 -05:00 committed by GitHub
parent 0a96df6f89
commit 92b0564dc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 11 deletions

View File

@ -3134,17 +3134,16 @@ object Classpaths {
}).value),
csrSameVersions ++= {
partialVersion(scalaVersion.value) match {
// See https://github.com/sbt/sbt/issues/8224
// Scala 3.8+ should align only Scala3_8Artifacts
case Some((3, minor)) if minor >= 8 =>
ScalaArtifacts.Scala3_8Artifacts
.map(a => InclExclRule(scalaOrganization.value, a))
.toSet :: Nil
case Some((major, minor)) if major == 2 || major == 3 =>
case Some((major, minor)) if major == 2 && minor < 13 =>
ScalaArtifacts.Artifacts
.map(a => InclExclRule(scalaOrganization.value, a))
.toSet :: Nil
case _ => Nil
// Due to the Scala 2.13-3.x sandwich, the absence of scala-reflect
// that corresponds with scala-library 3.8.x propagates to 2.13 builds as well.
case _ =>
ScalaArtifacts.Scala3_8Artifacts
.map(a => InclExclRule(scalaOrganization.value, a))
.toSet :: Nil
}
},
moduleName := normalizedName.value,

View File

@ -0,0 +1,12 @@
lazy val a = project
.settings(
scalaVersion := "3.8.1"
)
// (b / update) sbt.librarymanagement.ResolveException: Error downloading org.scala-lang:scala-reflect:3.8.1
lazy val b = project
.dependsOn(a)
.settings(
scalaVersion := "2.13.10",
libraryDependencies += "org.scala-lang" % "scala-reflect" % "2.13.10",
)

View File

@ -0,0 +1 @@
> update

View File

@ -3,12 +3,12 @@ import sbt.librarymanagement.InclExclRule
lazy val a = project.settings(
scalaVersion := "2.13.11",
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
TaskKey[Unit]("checkLibs") := checkLibs("2.13.11", (Compile/dependencyClasspath).value, ".*scala-(library|reflect).*"),
TaskKey[Unit]("checkLibs") := checkLibs("2.13.11", (Compile/dependencyClasspath).value, ".*scala-library.*"),
)
lazy val b = project.dependsOn(a).settings(
scalaVersion := "2.13.12",
TaskKey[Unit]("checkLibs") := checkLibs("2.13.12", (Compile/dependencyClasspath).value, ".*scala-(library|reflect).*"),
TaskKey[Unit]("checkLibs") := checkLibs("2.13.12", (Compile/dependencyClasspath).value, ".*scala-library.*"),
)
lazy val a3 = project.settings(

View File

@ -15,6 +15,5 @@ $ delete s2.13.14.txt
# without the default `csrSameVersions`, scala-reflect in b stays at 2.13.11
> set b/csrSameVersions := Nil
> b/update
-> b/checkLibs
> ak/checkLibs