GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: fix addParentPoms=true causes repositories to be ignored. by k-wall · Pull Request #1585 · apache/maven-dependency-plugin

Conversation

@k-wall

@k-wall k-wall commented Feb 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fix for #1028 - If addParentPoms is true, the plugin fails to respect any remote repositories declared in the POM leading to a build failure when resolving artefacts that do not exist in Maven Central.

When the failure occurs, it fails as follows. (Note: In this case the org.apache.kafka:kafka-clients:pom:4.2.0 is available in staging repo which is referenced in the project's POM).

[INFO] Artifact org.apache.kafka:kafka-clients:pom:4.2.0 is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from [central (https://repo.maven.apache.org/maven2, default, releases)]
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/kafka/kafka-clients/4.2.0/kafka-clients-4.2.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.347 s
[INFO] Finished at: 2026-02-03T18:10:26Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.9.0:copy-dependencies (copy-deps) on project test: Coud not build project for org.apache.kafka:kafka-clients:jar:4.2.0: Error resolving project artifact: The following artifacts could not be resolved: org.apache.kafka:kafka-clients:pom:4.2.0 (present, but unavailable): Could not find artifact org.apache.kafka:kafka-clients:pom:4.2.0 in central (https://repo.maven.apache.org/maven2) for project org.apache.kafka:kafka-clients:jar:4.2.0 -> [Help 1]

This change propagates the remote repositories from the project to the ProjectBuildingRequest used build the project for the parent artefacts. The approach was inspired by https://github.com/apache/maven-javadoc-plugin/blob/ace4fe073378474b53296bd8c7a3f4a3faa44e17/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java#L2364

I don't know the Maven API well, so I'm hoping someone can give me a thumbs up that the approach is generally in the right direction. I'll then spend time adding test case(s).

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
  • In any other case, please file an Apache Individual Contributor License Agreement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@k-wall
k-wall marked this pull request as draft February 4, 2026 14:00
k-wall
k-wall commented Feb 4, 2026
View reviewed changes
Comment thread .../java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@k-wall

k-wall commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

Anyone?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@k-wall

k-wall commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

I would really like to see this issue resolved, would any commiter be able to comment please?

slawekjaranowski reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

slawekjaranowski
slawekjaranowski reviewed May 12, 2026
View reviewed changes
Comment thread .../java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java Outdated
ProjectBuildingRequest buildingRequest =
new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
buildingRequest.setProcessPlugins(false);
if (getProject().getRemoteArtifactRepositories() != null

@slawekjaranowski slawekjaranowski May 12, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

getProject().getRemoteArtifactRepositories() it should be never null

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slawekjaranowski slawekjaranowski linked an issue May 12, 2026 that may be closed by this pull request
[MDEP-592] Regression: -Dmdep.addParentPoms=true causes <repositories> to be ignored #1028
Closed
@slawekjaranowski slawekjaranowski added the bug Something isn't working label May 12, 2026
@k-wall @slawekjaranowski
fix: fix addParentPoms=true causes repositories to be ignored.
2073584
Signed-off-by: Keith Wall <[email protected]>
@slawekjaranowski
slawekjaranowski force-pushed the issue-1028 branch from 32566ad to 2073584 Compare May 12, 2026 21:32
slawekjaranowski
slawekjaranowski reviewed May 12, 2026
View reviewed changes
Comment thread .../java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java Outdated
new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
buildingRequest.setProcessPlugins(false);
if (getProject().getRemoteArtifactRepositories() != null
&& !getProject().getRemoteArtifactRepositories().isEmpty()) {

@slawekjaranowski slawekjaranowski May 12, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

also getProject().getRemoteArtifactRepositories() should never be empty

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slawekjaranowski

slawekjaranowski commented May 12, 2026

Copy link
Copy Markdown
Member

@k-wall thanks, I have rebased with current muster to trigger CI build

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski slawekjaranowski self-assigned this May 12, 2026
slawekjaranowski
slawekjaranowski approved these changes May 16, 2026
View reviewed changes
@slawekjaranowski
slawekjaranowski marked this pull request as ready for review May 16, 2026 09:59
@slawekjaranowski slawekjaranowski added this to the 3.11.0 milestone May 16, 2026
elharo
elharo reviewed May 16, 2026
View reviewed changes

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can there be an IT or unit test for this?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@k-wall

k-wall commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Great, thanks for picking up. I'll see if I can add a test.

slawekjaranowski reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski

slawekjaranowski commented May 19, 2026

Copy link
Copy Markdown
Member

@k-wall thanks, I have rebased with current muster to trigger CI build

You can look at my coments

k-wall reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

k-wall added 2 commits May 20, 2026 12:37
@k-wall
test: add integration test for MDEP-592 addParentPoms repository fix
64bd416
Add integration test to verify that when using copy-dependencies with
addParentPoms=true, the plugin correctly propagates the project's remote
repositories to the ProjectBuildingRequest when resolving parent POMs.

The test uses the "fake-remote-repository" pattern to ensure the custom
repository is NOT mirrored by MRM (Mock Repository Manager). This is critical
because MRM is configured as a global mirror in src/it/mrm/settings.xml with:
  <mirrorOf>*,!fake-remote-repository</mirrorOf>

By using id "fake-remote-repository", the repository is:
- NOT mirrored by MRM
- NOT inherited in the session's repository configuration
- ONLY available if explicitly propagated via setRemoteRepositories()

This ensures the test actually validates the fix.

TEST VALIDATION:
- WITHOUT fix: Test FAILS with "Could not build project" error at
  buildProjectFromArtifact() because fake-remote-repository is not propagated
- WITH fix: Test PASSES, parent POM successfully resolved and copied

Test structure (following copy-from-remote-repository pattern):
- repo/: Local repository with test artifacts (test-parent, test-child)
- pom.xml: Declares fake-remote-repository and dependency on test-child
- setup.bsh: Cleans local cache to force fresh resolution
- verify.bsh: Validates parent POM was copied to output

Assisted-by: Claude Sonnet 4.5 <[email protected]>
Signed-off-by: Keith Wall <[email protected]>
@k-wall
fix: simplify MDEP-592 fix per reviewer feedback
09b4b4a
Remove unnecessary null and empty checks for getProject().getRemoteArtifactRepositories()
as the reviewer (slawekjaranowski) noted these should never be null or empty in Maven.

Signed-off-by: Keith Wall <[email protected]>
@k-wall

k-wall commented May 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I've added an IT and believe I have addressed the feedback. Please take another look.

slawekjaranowski reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

elharo
elharo approved these changes May 20, 2026
View reviewed changes
@slawekjaranowski
slawekjaranowski merged commit 70b5356 into apache:master May 20, 2026
17 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@slachiewicz slachiewicz mentioned this pull request Oct 7, 2026
[MDEP-696] copy:dependencies fails with addParentPom using SNAPSHOT #1206
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@elharo elharo elharo approved these changes
@slawekjaranowski slawekjaranowski slawekjaranowski approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slawekjaranowski slawekjaranowski

Labels

bug Something isn't working

Projects

None yet

Milestone

3.11.0

Development

Successfully merging this pull request may close these issues.

[MDEP-592] Regression: -Dmdep.addParentPoms=true causes <repositories> to be ignored

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@k-wall @slawekjaranowski @elharo
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.