fix(gradle): honor replaces-base for Maven Central fallback#14822
Merged
thavaahariharangit merged 2 commits intomainfrom Apr 27, 2026
Merged
fix(gradle): honor replaces-base for Maven Central fallback#14822thavaahariharangit merged 2 commits intomainfrom
replaces-base for Maven Central fallback#14822thavaahariharangit merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Gradle’s repository resolution so that when a Maven credential is marked replaces-base: true, Dependabot treats that private registry as the “base” repository and avoids default Maven Central fallback.
Changes:
- Add
credentialssupport toGradle::FileParser::RepositoriesFinderand use it to replace Maven Central with thereplaces-baseregistry. - Wire credentials through
PackageDetailsFetcherwhen determining dependency repository URLs. - Add/update specs to verify repository selection and source URLs when
replaces-baseis present.
Show a summary per file
| File | Description |
|---|---|
| gradle/lib/dependabot/gradle/file_parser/repositories_finder.rb | Adds credential-aware “central” URL resolution and maps mavenCentral()/fallback to a replaces-base registry. |
| gradle/lib/dependabot/gradle/package/package_details_fetcher.rb | Passes credentials into RepositoriesFinder when building repository details for version lookups. |
| gradle/spec/dependabot/gradle/file_parser/repositories_finder_spec.rb | Adds coverage for replaces-base behavior in repository URL discovery (including mavenCentral() mapping). |
| gradle/spec/dependabot/gradle/package/package_details_fetcher_spec.rb | Adds coverage ensuring version source URLs reflect the replaces-base registry. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 1
replaces-base for Maven Central fallback
markhallen
approved these changes
Apr 27, 2026
Contributor
Author
|
confirmed working as expected in the workflow: https://github.com/thavaahariharangit/java-private-registry-test-13249-1/actions/runs/24988250907/job/73166950498 |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
Before this change, teams often had to rely on
settings.gradleto reliably prevent public fallback during Dependabot Gradle updates.This fix makes that behavior explicit: when a Maven credential is marked with
replaces-base: true, Dependabot treats that private registry as the base source and avoids default fallback to Maven Central.Note:
If a project explicitly declares additional public repositories in Gradle configuration, those declarations still need to be governed by repository policy (for example, via
settings.gradlerepository mode).Anything you want to highlight for special attention from reviewers?
This PR ensures that
replaces-base: trueis honored for Gradle dependency resolution — when a private registry is configured with this flag, Dependabot will no longer fall back to the public Maven Central registry.A follow-up PR is planned to improve the behavior further: even without replaces-base: true, Dependabot should prefer configured registries before falling back to maven central(default) ones. This is particularly important for projects with multiple registries, where the current behavior requires teams to rely on
settings.gradleto control resolution order.How will you know you've accomplished your goal?
Validation was done using this workflow run:: https://github.com/thavaahariharangit/java-private-registry-test-13249-1/actions/runs/24915740405/job/72967316407
Before this change, even with
replaces-base: true, Gradle resolution still fell back to the public registry and proposed an update to1.3.6:After this fix, with
replaces-base: true, Dependabot no longer falls back to the public registry, and the proposed update comes from the private registry path (1.2):Checklist