diff --git a/lib/modules/datasource/sbt-package/index.spec.ts b/lib/modules/datasource/sbt-package/index.spec.ts index 847ab5bfeddb31eb8d11232354b4fdc7655b2073..55f65dae6960a3f28834a8557b7fda096ec6d32d 100644 --- a/lib/modules/datasource/sbt-package/index.spec.ts +++ b/lib/modules/datasource/sbt-package/index.spec.ts @@ -32,6 +32,8 @@ describe('modules/datasource/sbt-package/index', () => { .get('/maven/org/scalatest/') .reply(404) .get('/maven/org.scalatest/') + .reply(404) + .get('/maven/org/scalatest/scalatest/maven-metadata.xml') .reply(404); const res = await getPkgReleases({ @@ -52,6 +54,10 @@ describe('modules/datasource/sbt-package/index', () => { .get('/maven2/com/example/empty/') .reply(200, '') .get('/maven2/com.example/') + .reply(404) + .get('/maven2/com/example/empty/maven-metadata.xml') + .reply(404) + .get('/maven2/com/example/empty/index.html') .reply(404); const res = await getPkgReleases({ @@ -206,10 +212,14 @@ describe('modules/datasource/sbt-package/index', () => { }); }); - it('falls back to Maven for GitLab-hosted packages', async () => { + it('falls back to Maven for orgarization root folder non-listable repositories', async () => { httpMock .scope('https://gitlab.com/api/v4/projects/123/packages/maven/') - .get('/org/example/example/maven-metadata.xml') + .get('/org/example/') + .reply(404) + .get('/org.example/') + .reply(404) + .get('/org/example/example_2.13/maven-metadata.xml') .reply( 200, ` @@ -227,15 +237,15 @@ describe('modules/datasource/sbt-package/index', () => { </metadata> ` ) - .head('/org/example/example/1.2.3/example-1.2.3.pom') + .head('/org/example/example_2.13/1.2.3/example_2.13-1.2.3.pom') .reply(200) - .get('/org/example/example/1.2.3/example-1.2.3.pom') + .get('/org/example/example_2.13/1.2.3/example_2.13-1.2.3.pom') .reply(200); const res = await getPkgReleases({ versioning: mavenVersioning.id, datasource: SbtPackageDatasource.id, - depName: 'org.example:example', + depName: 'org.example:example_2.13', registryUrls: [ 'https://gitlab.com/api/v4/projects/123/packages/maven/', ], diff --git a/lib/modules/datasource/sbt-package/index.ts b/lib/modules/datasource/sbt-package/index.ts index 6342567e8f16d01aab86eff5624c598cf0e58e83..36818864ed581feb6d223d28241aeec2c42cfd81 100644 --- a/lib/modules/datasource/sbt-package/index.ts +++ b/lib/modules/datasource/sbt-package/index.ts @@ -1,6 +1,5 @@ import { XmlDocument } from 'xmldoc'; import { logger } from '../../../logger'; -import { detectPlatform } from '../../../util/common'; import { Http } from '../../../util/http'; import { regEx } from '../../../util/regex'; import { ensureTrailingSlash } from '../../../util/url'; @@ -153,12 +152,6 @@ export class SbtPackageDatasource extends MavenDatasource { return null; } - const platform = detectPlatform(registryUrl); - if (platform === 'gitlab') { - const mavenReleases = await super.getReleases(config); - return mavenReleases; - } - const [groupId, artifactId] = packageName.split(':'); const groupIdSplit = groupId.split('.'); const artifactIdSplit = artifactId.split('_'); @@ -200,6 +193,14 @@ export class SbtPackageDatasource extends MavenDatasource { } } + logger.debug( + `No versions discovered for ${packageName} listing organization root package folder, fallback to maven datasource for version discovery` + ); + const mavenReleaseResult = await super.getReleases(config); + if (mavenReleaseResult) { + return mavenReleaseResult; + } + logger.debug( `No versions found for ${packageName} in ${searchRoots.length} repositories` );