Fix copy and unpack for artifacts with unavailable parents#1664
Open
brunoborges wants to merge 2 commits into
Open
Fix copy and unpack for artifacts with unavailable parents#1664brunoborges wants to merge 2 commits into
brunoborges wants to merge 2 commits into
Conversation
Preserve descriptor-based relocation while falling back to direct artifact resolution when an artifact descriptor cannot be read. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 32540765-8b96-4d21-aafb-e09cc896cd8f
rmannibucau
approved these changes
Jul 17, 2026
There was a problem hiding this comment.
Pull request overview
This PR restores dependency:copy / dependency:unpack usability for artifacts whose POM descriptor resolution fails due to an unavailable parent POM, by introducing a controlled fallback that resolves the original artifact coordinates directly (while still preferring descriptor-based relocation when available).
Changes:
- Add
ResolverUtil.resolveArtifactWithFallback(...)to fall back to direct resolution whenreadArtifactDescriptorfails, preserving the original descriptor exception as suppressed context if resolution still fails. - Wire the fallback into from-configuration goals via
AbstractFromConfigurationMojo#getArtifact. - Add unit coverage for the fallback path and an integration test project/repository artifact that reproduces the missing-parent scenario.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/org/apache/maven/plugins/dependency/utils/ResolverUtil.java | Introduces fallback artifact resolution and extracts a direct-resolve helper. |
| src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java | Switches from descriptor-mandatory resolution to fallback-enabled resolution for configured artifact items. |
| src/test/java/org/apache/maven/plugins/dependency/utils/ResolverUtilTest.java | Adds a resolver unit test covering descriptor-failure fallback behavior. |
| src/it/projects/copy-broken-parent/pom.xml | Adds an IT project exercising dependency:copy against an artifact with a missing parent POM. |
| src/it/projects/copy-broken-parent/invoker.properties | Defines invoker goals for the new IT project. |
| src/it/projects/copy-broken-parent/verify.groovy | Verifies the copied artifact is produced in the expected location. |
| src/it/mrm/repository/broken-parent-artifact-1.0.pom | Adds a mock repository artifact whose parent is intentionally unavailable to reproduce the regression. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Maven Dependency Plugin 3.11.0 made artifact descriptor resolution mandatory for
copyandunpack, which prevents otherwise available artifacts from being processed when their POM references an unavailable snapshot parent.This change preserves descriptor-based relocation support, but scopes a fallback to the from-configuration goals: when descriptor reading fails, the original artifact coordinates are resolved directly. Artifact resolution failures still fail the goal and retain the descriptor exception as suppressed context.
A repository-backed integration test reproduces the unavailable snapshot-parent case, and focused resolver coverage verifies the fallback. Existing copy and unpack relocation integration tests continue to pass.
Fixes: #1642