Skip to content

[WIP] Extract Maven repo interaction logic for JVM ecosystems reuse#14721

Draft
AbhishekBhaskar wants to merge 1 commit intomainfrom
abhishekbhaskar/extract-maven-repo-interaction-logic
Draft

[WIP] Extract Maven repo interaction logic for JVM ecosystems reuse#14721
AbhishekBhaskar wants to merge 1 commit intomainfrom
abhishekbhaskar/extract-maven-repo-interaction-logic

Conversation

@AbhishekBhaskar
Copy link
Copy Markdown
Contributor

What are you trying to accomplish?

Extracts Maven repository interaction logic from Maven::Package::PackageDetailsFetcher into a new abstract base class Maven::Shared::SharedMavenRepositoryClient, enabling SBT (and other JVM ecosystems) to reuse Maven repository resolution without duplicating code.
SBT resolves dependencies from Maven repositories using the same maven-metadata.xml format, URL conventions, and auth patterns as Maven. Rather than duplicating ~300 lines of repository client logic in the SBT ecosystem, we extract it into a shared abstract class that both Maven and SBT can inherit from.

Changes:
New file: shared_maven_repository_client.rb

  • Abstract base class (~340 lines) under Dependabot::Maven::Shared
  • Extracted logic: URL construction (dependency_parts, dependency_base_url, dependency_metadata_url, dependency_files_url), metadata fetching (XML + HTML), version extraction, response checking, forbidden URL tracking, released? checks, credential/auth header handling, and per-repository metadata caching
  • Defines 3 abstract methods subclasses must implement: dependency, credentials, repositories
  • Provides overridable hooks: dependency_parts (for non-standard naming), central_repo_url (for credential-based overrides)

Modified file: package_details_fetcher.rb

  • Now inherits from SharedMavenRepositoryClient (was standalone class)
  • Reduced from ~470 lines to ~220 lines
  • Retains only Maven-specific logic:
    - fetch / releases — package details orchestration
    - released? — delegates to parent via super
    - repositories (override) — assembles credential repos + POM-declared repos
    - central_repo_url (override) — delegates to RepositoriesFinder
    - versions / versions_details_from_xml / versions_details_hash_from_html — version list assembly
    - repository_finder / pom_repository_details / pom — Maven POM helpers

Anything you want to highlight for special attention from reviewers?

Method What SBT implements
dependency attr_reader — same as Maven, no custom logic needed
credentials attr_reader — same as Maven, no custom logic needed
repositories SBT-specific: assemble repos from resolvers in build.sbt + credential repos via inherited credentials_repository_details

How will you know you've accomplished your goal?

If all the existing unit tests pass without failures.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@AbhishekBhaskar AbhishekBhaskar self-assigned this Apr 15, 2026
@github-actions github-actions bot added the L: java:maven Maven packages via Maven label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: java:maven Maven packages via Maven

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant