Update scala libraries according to dependency graph

There are a couple of settings / configs that affect this, summary
below. The change in this PR seems to be the most narrow.

`scalaModuleInfo.value.overrideScalaVersion` in sbt
  - affects how sbt to sets coursier's `forceScalaVersion` (see below)
  - used by librarymanagement.ivy. If true, add a OverrideScalaMediator
    See sbt/sbt#2634. Probably not relevant when using coursier.

`autoScalaLibrary` setting in sbt
  - automatically add `scala-library` (or `scala3-library`) as a project
    dependency
  - also used for `forceScalaVersion` (see below)

`CoursierConfiguration.autoScalaLibrary`
  - if `true` then Coursier `ResolutionParams.forceScalaVersion` is set
    to to `true`
  - initialized by sbt to
    `autoScalaLibrary.value &&
     !ScalaArtifacts.isScala3(sv) &&
     !Classpaths.isScala213(sv) &&        // added in this commit
     scalaModuleInfo.forall(_.overrideScalaVersion)`

coursier `ResolutionParams.forceScalaVersion`
  - if true, `scala-library` / `scala-reflect` / `scala-compiler` /
    `scalap` are forced to the scala version, not actually resolved
  - for Scala 3, the `scala3-library` and `scala3-compiler` versions
    are forced
This commit is contained in:
Lukas Rytz 2024-01-22 16:30:20 +01:00
parent d8d2b02e7e
commit 893997d1b6
2 changed files with 6 additions and 4 deletions

View File

@ -3934,6 +3934,8 @@ object Classpaths {
def deliverPattern(outputPath: File): String =
(outputPath / "[artifact]-[revision](-[classifier]).[ext]").absolutePath
private[sbt] def isScala213(sv: String) = sv.startsWith("2.13.")
private[sbt] def isScala2Scala3Sandwich(sbv1: String, sbv2: String): Boolean = {
def compare(a: String, b: String): Boolean =
a == "2.13" && (b.startsWith("0.") || b.startsWith("3"))

View File

@ -212,7 +212,7 @@ object LMCoursier {
scalaOrganization.value,
sv,
scalaBinaryVersion.value,
autoScalaLibrary.value && !ScalaArtifacts.isScala3(sv),
autoScalaLibrary.value && !ScalaArtifacts.isScala3(sv) && !Classpaths.isScala213(sv),
scalaModuleInfo.value,
allExcludeDependencies.value,
CoursierInputsTasks.credentialsTask.value,
@ -240,7 +240,7 @@ object LMCoursier {
scalaOrganization.value,
sv,
scalaBinaryVersion.value,
autoScalaLibrary.value && !ScalaArtifacts.isScala3(sv),
autoScalaLibrary.value && !ScalaArtifacts.isScala3(sv) && !Classpaths.isScala213(sv),
scalaModuleInfo.value,
allExcludeDependencies.value,
CoursierInputsTasks.credentialsTask.value,
@ -268,7 +268,7 @@ object LMCoursier {
scalaOrganization.value,
sv,
scalaBinaryVersion.value,
autoScalaLibrary.value && !ScalaArtifacts.isScala3(sv),
autoScalaLibrary.value && !ScalaArtifacts.isScala3(sv) && !Classpaths.isScala213(sv),
scalaModuleInfo.value,
allExcludeDependencies.value,
CoursierInputsTasks.credentialsTask.value,
@ -296,7 +296,7 @@ object LMCoursier {
scalaOrganization.value,
sv,
scalaBinaryVersion.value,
autoScalaLibrary.value && !ScalaArtifacts.isScala3(sv),
autoScalaLibrary.value && !ScalaArtifacts.isScala3(sv) && !Classpaths.isScala213(sv),
scalaModuleInfo.value,
allExcludeDependencies.value,
CoursierInputsTasks.credentialsTask.value,