gnodet opened a new pull request, #12870: URL: https://github.com/apache/maven/pull/12870
## Summary - Fixes SNAPSHOT parent POM resolution failure when mirror injection produces multiple repository entries with the same mirror ID but different snapshot/release policies (regression in 4.0.0-rc-6) - Adds pre-deduplication of repositories by ID in `ModelBuilderSessionState.repos()`, merging policies so that enabled wins over disabled for each policy type - Prevents the Aether resolver's `aggregateRepositories()`/`mergeMirrors()` from dropping the snapshot-enabled policy during dedup ## Root Cause When `<mirrorOf>*</mirrorOf>` maps both `central` (releases-only) and a profile-defined repo (releases+snapshots) to the same mirror ID, `MavenExecutionRequest.getRemoteRepositories()` returns two entries like: - `my-mirror (releases)` - `my-mirror (releases+snapshots)` In `DefaultModelBuilder`, these are stored as-is in `ModelBuilderSessionState.repositories`. When the resolver deduplicates them in `toResolvingRepositories()` → `aggregateRepositories()` → `mergeMirrors()`, the recessive's snapshot-enabled mirrored repo has the same key as the dominant's releases-only mirrored repo, so it's skipped. The result is a single repo with snapshots **disabled**, causing SNAPSHOT parent resolution to fail with "artifact not found". ## Fix `ModelBuilderSessionState.repos()` now calls `mergeRepositoriesById()` which: 1. Groups repositories by ID (preserving insertion order) 2. For duplicate IDs, merges policies: `enabled` wins for both release and snapshot policies 3. Preserves URL, proxy, authentication from the dominant (first) entry This ensures a single repository entry with the most permissive policy combination reaches the resolver. ## Test plan - [x] Added `testDuplicateMirrorReposMergedForSnapshotResolution()` — verifies that repos with the same mirror ID but different snapshot policies are merged into one with snapshots enabled - [x] Added `testDuplicateMirrorReposMergedReversePolicyOrder()` — verifies reverse-order merging (dominant has snapshots-only, recessive has releases-only) - [x] All 576 tests in `maven-impl` pass - [ ] CI build 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
