diff --git a/lib/modules/manager/sbt/extract.spec.ts b/lib/modules/manager/sbt/extract.spec.ts index da3c83ae8c74ae40641f4698ce001f7885782edc..b768d6d47a2af4c50e2b5b4d636adf8b406dcdb7 100644 --- a/lib/modules/manager/sbt/extract.spec.ts +++ b/lib/modules/manager/sbt/extract.spec.ts @@ -223,6 +223,21 @@ describe('modules/manager/sbt/extract', () => { }); }); + it('extracts correct scala library when dealing with scala 3', () => { + const content = ` + scalaVersion := "3.1.1" + `; + + expect(extractPackageFile(content)).toMatchObject({ + deps: [ + { + packageName: 'org.scala-lang:scala3-library_3', + currentValue: '3.1.1', + }, + ], + }); + }); + it('extracts deps when scala version is defined in a variable with ThisBuild scope', () => { const content = ` val ScalaVersion = "2.12.10" diff --git a/lib/modules/manager/sbt/extract.ts b/lib/modules/manager/sbt/extract.ts index bf4478d60c0c599b5a3a1eaf126ecbc9f3cb7739..2a501405e89235377f7effb2b05ef48b2c782bff 100644 --- a/lib/modules/manager/sbt/extract.ts +++ b/lib/modules/manager/sbt/extract.ts @@ -8,6 +8,8 @@ import { SBT_PLUGINS_REPO, SbtPluginDatasource, } from '../../datasource/sbt-plugin'; +import { get } from '../../versioning'; +import * as mavenVersioning from '../../versioning/maven'; import { REGISTRY_URLS } from '../gradle/parser/common'; import type { PackageDependency, PackageFile } from '../types'; import { normalizeScalaVersion } from './util'; @@ -49,10 +51,17 @@ const scalaVersionMatch = q ) .handler((ctx) => { if (ctx.scalaVersion) { + const version = get(mavenVersioning.id); + + let packageName = 'org.scala-lang:scala-library'; + if (version.getMajor(ctx.scalaVersion) === 3) { + packageName = 'org.scala-lang:scala3-library_3'; + } + const dep: PackageDependency = { datasource: MavenDatasource.id, depName: 'scala', - packageName: 'org.scala-lang:scala-library', + packageName, currentValue: ctx.scalaVersion, separateMinorPatch: true, };