Skip to content

Commit

Permalink
fix(sbt): initialize registry urls for sbt version (#27667)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpriyasivakumar committed Mar 1, 2024
1 parent 17be5a0 commit 6da8fdc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
26 changes: 26 additions & 0 deletions lib/modules/manager/sbt/extract.spec.ts
Expand Up @@ -556,5 +556,31 @@ describe('modules/manager/sbt/extract', () => {
const packages = await extractAllPackageFiles({}, ['build.sbt']);
expect(packages).toBeEmpty();
});

it('extracts build properties correctly', async () => {
const buildProps = codeBlock`
sbt.version=1.6.0
`;
fs.readLocalFile.mockResolvedValueOnce(buildProps);
const packages = await extractAllPackageFiles({}, [
'project/build.properties',
]);
expect(packages).toMatchObject([
{
deps: [
{
datasource: 'github-releases',
packageName: 'sbt/sbt',
depName: 'sbt/sbt',
currentValue: '1.6.0',
replaceString: 'sbt.version=1.6.0',
versioning: 'semver',
extractVersion: '^v(?<version>\\S+)',
registryUrls: ['https://repo1.maven.org/maven2'],
},
],
},
]);
});
});
});
8 changes: 4 additions & 4 deletions lib/modules/manager/sbt/extract.ts
Expand Up @@ -334,6 +334,7 @@ export function extractPackageFile(
currentValue: sbtVersion,
replaceString: matchString,
extractVersion: '^v(?<version>\\S+)',
registryUrls: [],
};

return {
Expand Down Expand Up @@ -394,13 +395,12 @@ export async function extractAllPackageFiles(
}
for (const pkg of packages) {
for (const dep of pkg.deps) {
dep.registryUrls ??= [];
if (proxyUrls.length > 0) {
dep.registryUrls.unshift(...proxyUrls);
dep.registryUrls!.unshift(...proxyUrls);
} else if (dep.depType === 'plugin') {
dep.registryUrls.unshift(SBT_PLUGINS_REPO, SBT_MVN_REPO);
dep.registryUrls!.unshift(SBT_PLUGINS_REPO, SBT_MVN_REPO);
} else {
dep.registryUrls.unshift(SBT_MVN_REPO);
dep.registryUrls!.unshift(SBT_MVN_REPO);
}
}
}
Expand Down

0 comments on commit 6da8fdc

Please sign in to comment.