Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manager/sbt): Support for updating Scala 3 #19911

Merged
merged 9 commits into from Jan 23, 2023
18 changes: 18 additions & 0 deletions lib/modules/manager/sbt/__snapshots__/extract.spec.ts.snap
Expand Up @@ -104,6 +104,24 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
}
`;

exports[`modules/manager/sbt/extract extractPackageFile() extracts correct scala library when dealing with scala 3 1`] = `
{
"deps": [
{
"currentValue": "3.1.1",
"datasource": "maven",
"depName": "scala",
"packageName": "org.scala-lang:scala3-library_3",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"separateMinorPatch": true,
},
],
"packageFileVersion": undefined,
}
`;

viceice marked this conversation as resolved.
Show resolved Hide resolved
exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for generic use-cases 1`] = `
{
"deps": [
Expand Down
15 changes: 15 additions & 0 deletions lib/modules/manager/sbt/extract.spec.ts
Expand Up @@ -223,6 +223,21 @@ describe('modules/manager/sbt/extract', () => {
});
});

it('extracts correct scala library when dealing with scala 3', () => {
const content = `
viceice marked this conversation as resolved.
Show resolved Hide resolved
scalaVersion := "3.1.1"
`;

expect(extractPackageFile(content)).toMatchSnapshot({
aktowns marked this conversation as resolved.
Show resolved Hide resolved
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"
Expand Down
11 changes: 10 additions & 1 deletion lib/modules/manager/sbt/extract.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
rarkins marked this conversation as resolved.
Show resolved Hide resolved
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,
};
Expand Down