Skip to content

feat(cli): add Maven ecosystem resolver#17

Merged
amondnet merged 9 commits into
mainfrom
15-track-maven-resolver-20260408
Apr 8, 2026
Merged

feat(cli): add Maven ecosystem resolver#17
amondnet merged 9 commits into
mainfrom
15-track-maven-resolver-20260408

Conversation

@amondnet

@amondnet amondnet commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add MavenResolver class implementing EcosystemResolver interface
  • Primary lookup via Maven Central Search API, fallback to POM XML for GitHub repo extraction
  • Support maven:groupId:artifactId spec format (e.g. maven:com.google.guava:guava)
  • Register in resolver index — getResolver('maven') now works

Refs #15

Test plan

  • bun --cwd packages/cli test test/resolvers/maven.test.ts — 10 tests pass
  • bun --cwd packages/cli test test/resolvers/ — all 54 resolver tests pass
  • bun run --cwd packages/cli lint — clean

Summary by cubic

Adds a Maven resolver to the CLI so maven:groupId:artifactId specs resolve to GitHub repos, addressing #15. It uses Maven Central for versioning and prefers Search API scm.url, with fallbacks to maven-metadata.xml and the POM.

  • New Features
    • Added MavenResolver implementing EcosystemResolver for maven:groupId:artifactId (e.g., maven:com.google.guava:guava) and explicit versions; registered so getResolver('maven') works.
    • Repo detection prefers Search API scm.url (default core query), then POM (<scm><url> then <url>) normalized via parseRepoUrl().
    • Version lookup uses Maven Central Search API; on failure, resolves latest via maven-metadata.xml or uses explicit version directly, then falls back to POM for repo extraction. Returns ref as v{version} with {version} fallback.

Written for commit 078e47e. Summary will update on new commits.

Verification Checklist

  • bun --cwd packages/cli test test/resolvers/maven.test.ts — 18 tests pass
  • bun --cwd packages/cli test test/resolvers/index.test.ts — 5 tests pass
  • bun --cwd packages/cli test test/resolvers/ — all 62 resolver tests pass
  • bun run --cwd packages/cli lint — clean

@amondnet amondnet linked an issue Apr 8, 2026 that may be closed by this pull request
18 tasks
@codecov

codecov Bot commented Apr 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.24242% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/cli/src/resolvers/maven.ts 99.23% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 8, 2026

Copy link
Copy Markdown

Deploying ask-registry with  Cloudflare Pages  Cloudflare Pages

Latest commit: 078e47e
Status:⚡️  Build in progress...

View logs

@amondnet amondnet marked this pull request as ready for review April 8, 2026 03:50
@amondnet amondnet mentioned this pull request Apr 8, 2026
18 tasks
amondnet added a commit that referenced this pull request Apr 8, 2026
Move track to completed/, mark status as review.
PR #17 ready for review.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 3 files (changes from recent commits).

Requires human review: This is a new feature implementation adding a Maven ecosystem resolver. It contains non-trivial logic including API interactions and regex-based XML parsing that requires human review.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Requires human review: New feature adding a non-trivial ecosystem resolver. While isolated, it includes complex logic like regex-based XML parsing and external API integration that requires human review.

Architecture diagram
sequenceDiagram
    participant CLI as CLI Core
    participant Index as Resolver Index
    participant Maven as NEW: MavenResolver
    participant SearchAPI as Maven Central Search API
    participant MavenRepo as Maven Central Repository (repo1)

    Note over CLI, MavenRepo: maven:groupId:artifactId Resolution Flow

    CLI->>Index: CHANGED: getResolver('maven')
    Index-->>CLI: MavenResolver instance

    CLI->>Maven: NEW: resolve(name, version)
    Maven->>Maven: Parse "groupId:artifactId"

    rect rgb(240, 240, 240)
    Note right of Maven: Version Resolution
    alt version is 'latest'
        Maven->>SearchAPI: GET /solrsearch?q=g:G+AND+a:A
        alt Search API Success
            SearchAPI-->>Maven: Latest version + scmUrl
        else Search API Failure
            Maven->>MavenRepo: NEW: GET /.../maven-metadata.xml
            MavenRepo-->>Maven: XML with <release> tag
        end
    else explicit version provided
        Maven->>SearchAPI: GET /solrsearch?q=...&v=V (Try for scmUrl)
        SearchAPI-->>Maven: Version metadata
    end
    end

    rect rgb(240, 240, 240)
    Note right of Maven: Repository Mapping (Priority Flow)
    alt scmUrl found in Search API docs
        Maven->>Maven: parseRepoUrl(scmUrl)
    else scmUrl missing or invalid
        Maven->>MavenRepo: NEW: GET /.../{artifactId}-{version}.pom
        MavenRepo-->>Maven: POM XML content
        Maven->>Maven: NEW: extractRepoFromPom() (Regex <scm> or <url>)
    end
    end

    alt GitHub URL Resolved
        Maven-->>CLI: ResolveResult { repo, ref: "v{v}", resolvedVersion: "{v}" }
    else No GitHub URL found
        Maven-->>CLI: Throw Error (Suggest 'owner/repo' format)
    end
Loading

amondnet added 8 commits April 8, 2026 12:57
Add spec and plan for Maven ecosystem resolver implementation.
Refs #15
Implement MavenResolver class following existing resolver patterns.
Primary: Maven Central Search API for version resolution.
Fallback: POM XML download for GitHub repo extraction.
Supports groupId:artifactId format (e.g. maven:com.google.guava:guava).

Refs #15
Add 'maven' to SupportedEcosystem type and resolvers record.
getResolver('maven') now returns a MavenResolver instance.

Refs #15
Fix regexp/match-any and e18e/prefer-static-regex lint violations.
Mark all implementation tasks complete in plan.

Refs #15
- FR-5: Check Search API scmUrl field before falling back to POM XML
- FR-4/AC-3: When Search API is unavailable, fall back to
  maven-metadata.xml for version resolution + POM for repo extraction
- Explicit versions skip Search API for version resolution on failure

Refs #15
- Use default core (not GAV) for scmUrl lookup so scm.url field is
  actually returned by Maven Central Search API
- Add 5 missing test cases: explicit version scmUrl, <latest> only
  metadata, malformed metadata, trailing colon, non-GitHub SCM fallback

Refs #15
Move track to completed/, mark status as review.
PR #17 ready for review.
@amondnet amondnet force-pushed the 15-track-maven-resolver-20260408 branch from 2e27cb3 to 8db055e Compare April 8, 2026 03:57
@amondnet amondnet merged commit 95ea4b8 into main Apr 8, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

track: maven-resolver-20260408

1 participant