Skip to content

Fix copy and unpack for artifacts with unavailable parents#1664

Open
brunoborges wants to merge 2 commits into
apache:masterfrom
brunoborges:brunoborges-issue-1642-snapshot-parent-download-fix
Open

Fix copy and unpack for artifacts with unavailable parents#1664
brunoborges wants to merge 2 commits into
apache:masterfrom
brunoborges:brunoborges-issue-1642-snapshot-parent-download-fix

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

Maven Dependency Plugin 3.11.0 made artifact descriptor resolution mandatory for copy and unpack, 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

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
@slawekjaranowski slawekjaranowski added the bug Something isn't working label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 when readArtifactDescriptor fails, 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.

Comment thread src/test/java/org/apache/maven/plugins/dependency/utils/ResolverUtilTest.java Outdated
Comment thread src/it/projects/copy-broken-parent/pom.xml
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3.11.0 broke download of dependencies with snapshot parent

4 participants