mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
fix(sbt-plugin): add new default registry URL (#29648)
Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com> Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
committed by
GitHub
parent
4f38e35f84
commit
0208d76027
@@ -8,7 +8,11 @@ import { compare } from '../../versioning/maven/compare';
|
||||
import { MavenDatasource } from '../maven';
|
||||
import { MAVEN_REPO } from '../maven/common';
|
||||
import { downloadHttpProtocol } from '../maven/util';
|
||||
import type { GetReleasesConfig, ReleaseResult } from '../types';
|
||||
import type {
|
||||
GetReleasesConfig,
|
||||
RegistryStrategy,
|
||||
ReleaseResult,
|
||||
} from '../types';
|
||||
import {
|
||||
getLatestVersion,
|
||||
normalizeRootRelativeUrls,
|
||||
@@ -22,7 +26,7 @@ export class SbtPackageDatasource extends MavenDatasource {
|
||||
|
||||
override readonly defaultVersioning = ivyVersioning.id;
|
||||
|
||||
override readonly registryStrategy = 'hunt';
|
||||
override readonly registryStrategy: RegistryStrategy = 'hunt';
|
||||
|
||||
override readonly sourceUrlSupport = 'package';
|
||||
override readonly sourceUrlNote =
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
This datasource finds SBT package updates from Maven repositories.
|
||||
|
||||
By default, Renovate checks `https://repo.maven.apache.org/maven2` for SBT packages.
|
||||
You can override the default behavior with the `registryUrls` config option.
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"matchDatasources": ["sbt-package"],
|
||||
"registryUrls": [
|
||||
"https://repo.maven.apache.org/maven2",
|
||||
"https://oss.sonatype.org/content/repositories/snapshots"
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -1,3 +1,4 @@
|
||||
import { codeBlock, html } from 'common-tags';
|
||||
import { getPkgReleases } from '..';
|
||||
import { Fixtures } from '../../../../test/fixtures';
|
||||
import * as httpMock from '../../../../test/http-mock';
|
||||
@@ -37,10 +38,12 @@ describe('modules/datasource/sbt-plugin/index', () => {
|
||||
.get('/maven2/org/scalatest/')
|
||||
.reply(
|
||||
200,
|
||||
'<a href="scalatest/" title=\'scalatest/\'>scalatest_2.12/</a>\n' +
|
||||
'<a href="scalatest_2.12/" title=\'scalatest_2.12/\'>scalatest_2.12/</a>\n' +
|
||||
"<a href='scalatest_sjs2.12/'>scalatest_2.12/</a>" +
|
||||
"<a href='scalatest_native2.12/'>scalatest_2.12/</a>",
|
||||
html`
|
||||
<a href="scalatest/">scalatest/</a>
|
||||
<a href="scalatest_2.12/">scalatest_2.12/</a>
|
||||
<a href="scalatest_sjs2.12/">scalatest_sjs2.12/</a>
|
||||
<a href="scalatest_native2.12/">scalatest_native2.12/</a>
|
||||
`,
|
||||
);
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
@@ -52,53 +55,46 @@ describe('modules/datasource/sbt-plugin/index', () => {
|
||||
.reply(200, "<a href='1.2.3/'>4.5.6/</a>");
|
||||
|
||||
httpMock
|
||||
.scope('https://repo.scala-sbt.org')
|
||||
.get('/scalasbt/sbt-plugin-releases/com.github.gseitz/')
|
||||
.reply(200, '');
|
||||
httpMock
|
||||
.scope('https://repo.scala-sbt.org')
|
||||
.get('/scalasbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/')
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/foundweekends/sbt-bintray/')
|
||||
.reply(
|
||||
200,
|
||||
'<html>\n' +
|
||||
'<head>\n' +
|
||||
'</head>\n' +
|
||||
'<body>\n' +
|
||||
'<pre><a href="scala_2.12/">scala_2.12/</a></pre>\n' +
|
||||
'</body>\n' +
|
||||
'</html>',
|
||||
html`
|
||||
<html>
|
||||
<head> </head>
|
||||
<body>
|
||||
<pre><a href="scala_2.12/">scala_2.12/</a></pre>
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
);
|
||||
httpMock
|
||||
.scope('https://repo.scala-sbt.org')
|
||||
.get(
|
||||
'/scalasbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/scala_2.12/',
|
||||
)
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/foundweekends/sbt-bintray/scala_2.12/')
|
||||
.reply(
|
||||
200,
|
||||
'\n' +
|
||||
'<html>\n' +
|
||||
'<head>\n' +
|
||||
'</head>\n' +
|
||||
'<body>\n' +
|
||||
'<pre><a href="sbt_1.0/">sbt_1.0/</a></pre>\n' +
|
||||
'</body>\n' +
|
||||
'</html>\n',
|
||||
html`
|
||||
<html>
|
||||
<head> </head>
|
||||
<body>
|
||||
<pre><a href="sbt_1.0/">sbt_1.0/</a></pre>
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
);
|
||||
httpMock
|
||||
.scope('https://repo.scala-sbt.org')
|
||||
.get(
|
||||
'/scalasbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/scala_2.12/sbt_1.0/',
|
||||
)
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/foundweekends/sbt-bintray/scala_2.12/sbt_1.0/')
|
||||
.reply(
|
||||
200,
|
||||
'\n' +
|
||||
'<html>\n' +
|
||||
'<head>\n' +
|
||||
'</head>\n' +
|
||||
'<body>\n' +
|
||||
'<pre><a href="0.5.5/">0.5.5/</a></pre>\n' +
|
||||
'</body>\n' +
|
||||
'</html>\n',
|
||||
html`
|
||||
<html>
|
||||
<head> </head>
|
||||
<body>
|
||||
<pre><a href="0.5.5/">0.5.5/</a></pre>
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
);
|
||||
|
||||
httpMock
|
||||
@@ -106,20 +102,28 @@ describe('modules/datasource/sbt-plugin/index', () => {
|
||||
.get('/maven2/io/get-coursier/')
|
||||
.reply(
|
||||
200,
|
||||
'<a href="sbt-coursier_2.10_0.13/">sbt-coursier_2.10_0.13/</a>\n' +
|
||||
'<a href="sbt-coursier_2.12_1.0/">sbt-coursier_2.12_1.0/</a>\n' +
|
||||
'<a href="sbt-coursier_2.12_1.0.0-M5/">sbt-coursier_2.12_1.0.0-M5/</a>\n' +
|
||||
'<a href="sbt-coursier_2.12_1.0.0-M6/">sbt-coursier_2.12_1.0.0-M6/</a>\n',
|
||||
html`
|
||||
<a href="sbt-coursier_2.10_0.13/">sbt-coursier_2.10_0.13/</a>
|
||||
<a href="sbt-coursier_2.12_1.0/">sbt-coursier_2.12_1.0/</a>
|
||||
<a href="sbt-coursier_2.12_1.0.0-M5/"
|
||||
>sbt-coursier_2.12_1.0.0-M5/</a
|
||||
>
|
||||
<a href="sbt-coursier_2.12_1.0.0-M6/"
|
||||
>sbt-coursier_2.12_1.0.0-M6/</a
|
||||
>
|
||||
`,
|
||||
);
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/io/get-coursier/sbt-coursier_2.12_1.0/')
|
||||
.reply(
|
||||
200,
|
||||
'<a href="2.0.0-RC2/">2.0.0-RC2/</a>\n' +
|
||||
'<a href="2.0.0-RC6-1/">2.0.0-RC6-1/</a>\n' +
|
||||
'<a href="2.0.0-RC6-2/">2.0.0-RC6-2/</a>\n' +
|
||||
'<a href="2.0.0-RC6-6/">2.0.0-RC6-6/</a>\n',
|
||||
html`
|
||||
<a href="2.0.0-RC2/">2.0.0-RC2/</a>
|
||||
<a href="2.0.0-RC6-1/">2.0.0-RC6-1/</a>
|
||||
<a href="2.0.0-RC6-2/">2.0.0-RC6-2/</a>
|
||||
<a href="2.0.0-RC6-6/">2.0.0-RC6-6/</a>
|
||||
`,
|
||||
);
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
@@ -128,12 +132,14 @@ describe('modules/datasource/sbt-plugin/index', () => {
|
||||
)
|
||||
.reply(
|
||||
200,
|
||||
'<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\n' +
|
||||
'<url>https://get-coursier.io/</url>\n' +
|
||||
'<scm>\n' +
|
||||
'<url>https://github.com/coursier/sbt-coursier</url>\n' +
|
||||
'</scm>\n' +
|
||||
'</project>\n',
|
||||
codeBlock`
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<url>https://get-coursier.io/</url>
|
||||
<scm>
|
||||
<url>https://github.com/coursier/sbt-coursier</url>
|
||||
</scm>
|
||||
</project>
|
||||
`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -169,8 +175,8 @@ describe('modules/datasource/sbt-plugin/index', () => {
|
||||
}),
|
||||
).toEqual({
|
||||
dependencyUrl:
|
||||
'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.foundweekends/sbt-bintray',
|
||||
registryUrl: 'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases',
|
||||
'https://repo.maven.apache.org/maven2/org/foundweekends/sbt-bintray',
|
||||
registryUrl: 'https://repo.maven.apache.org/maven2',
|
||||
releases: [{ version: '0.5.5' }],
|
||||
});
|
||||
});
|
||||
@@ -185,8 +191,8 @@ describe('modules/datasource/sbt-plugin/index', () => {
|
||||
}),
|
||||
).toEqual({
|
||||
dependencyUrl:
|
||||
'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.foundweekends/sbt-bintray',
|
||||
registryUrl: 'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases',
|
||||
'https://repo.maven.apache.org/maven2/org/foundweekends/sbt-bintray',
|
||||
registryUrl: 'https://repo.maven.apache.org/maven2',
|
||||
releases: [{ version: '0.5.5' }],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,22 +4,27 @@ import { regEx } from '../../../util/regex';
|
||||
import { ensureTrailingSlash } from '../../../util/url';
|
||||
import * as ivyVersioning from '../../versioning/ivy';
|
||||
import { compare } from '../../versioning/maven/compare';
|
||||
import { MAVEN_REPO } from '../maven/common';
|
||||
import { downloadHttpProtocol } from '../maven/util';
|
||||
import { SbtPackageDatasource } from '../sbt-package';
|
||||
import { getLatestVersion, parseIndexDir } from '../sbt-package/util';
|
||||
import type { GetReleasesConfig, ReleaseResult } from '../types';
|
||||
import type {
|
||||
GetReleasesConfig,
|
||||
RegistryStrategy,
|
||||
ReleaseResult,
|
||||
} from '../types';
|
||||
|
||||
export const SBT_PLUGINS_REPO =
|
||||
'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases';
|
||||
|
||||
export const defaultRegistryUrls = [SBT_PLUGINS_REPO];
|
||||
export const defaultRegistryUrls = [SBT_PLUGINS_REPO, MAVEN_REPO];
|
||||
|
||||
export class SbtPluginDatasource extends SbtPackageDatasource {
|
||||
static override readonly id = 'sbt-plugin';
|
||||
|
||||
override readonly defaultRegistryUrls = defaultRegistryUrls;
|
||||
|
||||
override readonly registryStrategy = 'hunt';
|
||||
override readonly registryStrategy: RegistryStrategy = 'merge';
|
||||
|
||||
override readonly defaultVersioning = ivyVersioning.id;
|
||||
|
||||
@@ -98,7 +103,9 @@ export class SbtPluginDatasource extends SbtPackageDatasource {
|
||||
const repoRoot = ensureTrailingSlash(registryUrl);
|
||||
const searchRoots: string[] = [];
|
||||
// Optimize lookup order
|
||||
searchRoots.push(`${repoRoot}${groupIdSplit.join('.')}`);
|
||||
if (!registryUrl.startsWith(MAVEN_REPO)) {
|
||||
searchRoots.push(`${repoRoot}${groupIdSplit.join('.')}`);
|
||||
}
|
||||
searchRoots.push(`${repoRoot}${groupIdSplit.join('/')}`);
|
||||
|
||||
for (let idx = 0; idx < searchRoots.length; idx += 1) {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
This datasource finds SBT plugin updates from Maven repositories.
|
||||
|
||||
By default, Renovate:
|
||||
|
||||
1. Checks `https://repo1.maven.org/maven2/` for SBT plugins
|
||||
1. If the above URL returns no results, then Renovate tries the _legacy_ URL: `https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases`
|
||||
|
||||
You can override the default behavior with the `registryUrls` config option.
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"matchDatasources": ["sbt-plugin"],
|
||||
"registryUrls": [
|
||||
"https://repo1.maven.org/maven2/",
|
||||
"https://oss.sonatype.org/content/repositories/snapshots",
|
||||
"https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases"
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -102,9 +102,9 @@ export interface DatasourceApi extends ModuleApi {
|
||||
|
||||
/**
|
||||
* Strategy to use when multiple registryUrls are available to the datasource.
|
||||
* first: only the first registryUrl will be tried and others ignored
|
||||
* hunt: registryUrls will be tried in order until one returns a result
|
||||
* merge: all registryUrls will be tried and the results merged if more than one returns a result
|
||||
* - `first`: only the first registryUrl will be tried and others ignored
|
||||
* - `hunt`: registryUrls will be tried in order until one returns a result
|
||||
* - `merge`: all registryUrls will be tried and the results merged if more than one returns a result
|
||||
*/
|
||||
registryStrategy?: RegistryStrategy | undefined;
|
||||
|
||||
|
||||
@@ -490,7 +490,7 @@ describe('modules/manager/sbt/extract', () => {
|
||||
registryUrls: [
|
||||
'http://example.org/repo',
|
||||
'https://example.org/ivy-repo/',
|
||||
'https://repo1.maven.org/maven2',
|
||||
'https://repo.maven.apache.org/maven2',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -499,7 +499,7 @@ describe('modules/manager/sbt/extract', () => {
|
||||
registryUrls: [
|
||||
'http://example.org/repo',
|
||||
'https://example.org/ivy-repo/',
|
||||
'https://repo1.maven.org/maven2',
|
||||
'https://repo.maven.apache.org/maven2',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -508,7 +508,7 @@ describe('modules/manager/sbt/extract', () => {
|
||||
registryUrls: [
|
||||
'http://example.org/repo',
|
||||
'https://example.org/ivy-repo/',
|
||||
'https://repo1.maven.org/maven2',
|
||||
'https://repo.maven.apache.org/maven2',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -517,7 +517,7 @@ describe('modules/manager/sbt/extract', () => {
|
||||
registryUrls: [
|
||||
'http://example.org/repo',
|
||||
'https://example.org/ivy-repo/',
|
||||
'https://repo1.maven.org/maven2',
|
||||
'https://repo.maven.apache.org/maven2',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -526,7 +526,7 @@ describe('modules/manager/sbt/extract', () => {
|
||||
registryUrls: [
|
||||
'http://example.org/repo',
|
||||
'https://example.org/ivy-repo/',
|
||||
'https://repo1.maven.org/maven2',
|
||||
'https://repo.maven.apache.org/maven2',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -535,7 +535,7 @@ describe('modules/manager/sbt/extract', () => {
|
||||
registryUrls: [
|
||||
'http://example.org/repo',
|
||||
'https://example.org/ivy-repo/',
|
||||
'https://repo1.maven.org/maven2',
|
||||
'https://repo.maven.apache.org/maven2',
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -551,7 +551,7 @@ describe('modules/manager/sbt/extract', () => {
|
||||
for (const dep of pkg.deps.filter((d) => d.depType === 'plugin')) {
|
||||
expect(dep.registryUrls).toStrictEqual([
|
||||
'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases',
|
||||
'https://repo1.maven.org/maven2',
|
||||
'https://repo.maven.apache.org/maven2',
|
||||
'https://example.com/repos/1/',
|
||||
'https://example.com/repos/2/',
|
||||
'https://example.com/repos/3/',
|
||||
@@ -563,7 +563,7 @@ describe('modules/manager/sbt/extract', () => {
|
||||
for (const pkg of packages) {
|
||||
for (const dep of pkg.deps.filter((d) => d.depType !== 'plugin')) {
|
||||
expect(dep.registryUrls).toStrictEqual([
|
||||
'https://repo1.maven.org/maven2',
|
||||
'https://repo.maven.apache.org/maven2',
|
||||
'https://example.com/repos/1/',
|
||||
'https://example.com/repos/2/',
|
||||
'https://example.com/repos/3/',
|
||||
|
||||
@@ -5,6 +5,7 @@ import { newlineRegex, regEx } from '../../../util/regex';
|
||||
import { parseUrl } from '../../../util/url';
|
||||
import { GithubReleasesDatasource } from '../../datasource/github-releases';
|
||||
import { MavenDatasource } from '../../datasource/maven';
|
||||
import { MAVEN_REPO } from '../../datasource/maven/common';
|
||||
import { SbtPackageDatasource } from '../../datasource/sbt-package';
|
||||
import {
|
||||
SBT_PLUGINS_REPO,
|
||||
@@ -41,8 +42,6 @@ interface Ctx {
|
||||
variableName?: string;
|
||||
}
|
||||
|
||||
const SBT_MVN_REPO = 'https://repo1.maven.org/maven2';
|
||||
|
||||
const scala = lang.createLang('scala');
|
||||
|
||||
const sbtVersionRegex = regEx(
|
||||
@@ -308,7 +307,7 @@ export function extractProxyUrls(
|
||||
if (extraction?.groups?.proxy) {
|
||||
extractedProxyUrls.push(extraction.groups.proxy);
|
||||
} else if (line.trim() === 'maven-central') {
|
||||
extractedProxyUrls.push(SBT_MVN_REPO);
|
||||
extractedProxyUrls.push(MAVEN_REPO);
|
||||
}
|
||||
}
|
||||
return extractedProxyUrls;
|
||||
@@ -418,9 +417,9 @@ export async function extractAllPackageFiles(
|
||||
if (proxyUrls.length > 0) {
|
||||
dep.registryUrls!.unshift(...proxyUrls);
|
||||
} else if (dep.depType === 'plugin') {
|
||||
dep.registryUrls!.unshift(SBT_PLUGINS_REPO, SBT_MVN_REPO);
|
||||
dep.registryUrls!.unshift(SBT_PLUGINS_REPO, MAVEN_REPO);
|
||||
} else {
|
||||
dep.registryUrls!.unshift(SBT_MVN_REPO);
|
||||
dep.registryUrls!.unshift(MAVEN_REPO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user