Skip to content

fix: fix addParentPoms=true causes repositories to be ignored.#1585

Draft
k-wall wants to merge 1 commit intoapache:masterfrom
k-wall:issue-1028
Draft

fix: fix addParentPoms=true causes repositories to be ignored.#1585
k-wall wants to merge 1 commit intoapache:masterfrom
k-wall:issue-1028

Conversation

@k-wall
Copy link

@k-wall k-wall commented Feb 4, 2026

TL;DR - I'm hoping for some feedback on whether the approach taken is reasonable or not. If yes, I'll add tests and then undraft the PR. Thank you for the attention.

Draft fix for #1028 - If addParentPoms is true, the plugin fails to respect any remote repositories declare in the POM leading to a build failure when resolving artefacts that do not exist in 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.

Signed-off-by: Keith Wall <kwall@apache.org>
@k-wall k-wall marked this pull request as draft February 4, 2026 14:00
ProjectBuildingRequest buildingRequest =
new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
buildingRequest.setProcessPlugins(false);
if (getProject().getRemoteArtifactRepositories() != null
Copy link
Author

Choose a reason for hiding this comment

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

@k-wall
Copy link
Author

k-wall commented Feb 10, 2026

Anyone?

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.

1 participant

Comments