Skip to content

Fix BUILD_CONSUMER profile activation for locally-resolved parent POMs - #11799

Merged
gnodet merged 2 commits into
apache:masterfrom
DavidTavoularis:fix/consumer-pom-profile-activation
Jun 17, 2026
Merged

gnodet merged 2 commits into
apache:masterfrom
DavidTavoularis:fix/consumer-pom-profile-activation

Conversation

@DavidTavoularis

Copy link
Copy Markdown
Contributor

Fixes #11798

When readParentLocally() finds a parent via resolveReactorModel() during BUILD_CONSUMER processing, derive(candidateSource) preserves the BUILD_CONSUMER request type. Since isBuildRequestWithActivation() returns false for BUILD_CONSUMER, POM profile activation is skipped for all parent POMs in the chain, leaving profile-defined properties (like BOM import versions) unresolved.

In contrast, resolveAndReadParentExternally() correctly creates a CONSUMER_PARENT request which allows profile activation.

The fix ensures readParentLocally() also uses CONSUMER_PARENT when the current request is BUILD_CONSUMER, consistent with the external resolution path.

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 Core IT successfully.

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.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review

Clean and well-targeted fix. The asymmetry was clear:

  • resolveAndReadParentExternally() → uses CONSUMER_PARENT → profiles activate ✓
  • readParentLocally() → inherits BUILD_CONSUMER → profiles skipped ✗

The fix makes them consistent. The test POM fixtures are minimal and clearly reproduce the issue.

Minor style suggestion: The if/else block could be slightly simplified:

ModelBuilderRequest parentRequest = request.getRequestType() == ModelBuilderRequest.RequestType.BUILD_CONSUMER
        ? ModelBuilderRequest.builder(request)
                .requestType(ModelBuilderRequest.RequestType.CONSUMER_PARENT)
                .source(candidateSource)
                .build()
        : ModelBuilderRequest.build(request, candidateSource);
derived = derive(parentRequest);

But that's a style preference, not a correctness concern.

This PR depends on #11768 and should merge after it. Looks good overall.

Claude Code on behalf of Guillaume Nodet

@DavidTavoularis

Copy link
Copy Markdown
Contributor Author

Simplified the if/else block to a ternary as suggested by the reviewer. Both paths still call derive(parentRequest), just with the request constructed differently depending on whether it's BUILD_CONSUMER or not.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The style suggestion from the previous review has been cleanly addressed -- the if/else block is now a ternary, and the logic is equivalent.

The fix remains correct: readParentLocally() now uses CONSUMER_PARENT when the request type is BUILD_CONSUMER, matching the behavior of resolveAndReadParentExternally(). The conditional (only for BUILD_CONSUMER) is appropriate since BUILD_PROJECT and BUILD_EFFECTIVE already get profile activation via isBuildRequestWithActivation().

The test is thorough -- it sets up the reactor via BUILD_PROJECT, then does a BUILD_CONSUMER build on the child, verifying both property resolution and managed dependency version interpolation.

Note: the dependency on #11768 is still open. This should merge after it.

Claude Code on behalf of Guillaume Nodet

When readParentLocally() finds a parent via resolveReactorModel()
during BUILD_CONSUMER processing, derive(candidateSource) preserves
the BUILD_CONSUMER request type. Since isBuildRequestWithActivation()
returns false for BUILD_CONSUMER, POM profile activation is skipped
for all parent POMs in the chain, leaving profile-defined properties
(like BOM import versions) unresolved.

In contrast, resolveAndReadParentExternally() correctly creates a
CONSUMER_PARENT request which allows profile activation.

The fix ensures readParentLocally() also uses CONSUMER_PARENT when
the current request is BUILD_CONSUMER, consistent with the external
resolution path.
@gnodet
gnodet force-pushed the fix/consumer-pom-profile-activation branch from b28b1f9 to 4d77807 Compare June 13, 2026 06:15
@gnodet
gnodet force-pushed the fix/consumer-pom-profile-activation branch from 4d77807 to 8899fc5 Compare June 13, 2026 07:38
@gnodet gnodet added this to the 4.0.0-rc-6 milestone Jun 16, 2026
@gnodet
gnodet merged commit d7b705e into apache:master Jun 17, 2026
41 of 42 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

@gnodet Please assign appropriate label to PR according to the type of change.

gnodet added a commit that referenced this pull request Jun 17, 2026
#11799)

When readParentLocally() finds a parent via resolveReactorModel()
during BUILD_CONSUMER processing, derive(candidateSource) preserved
the BUILD_CONSUMER request type. Since isBuildRequestWithActivation()
returns false for BUILD_CONSUMER, POM profile activation was skipped
for all parent POMs in the chain, leaving profile-defined properties
(like BOM import versions) unresolved.

The fix ensures readParentLocally() uses CONSUMER_PARENT when the
current request is BUILD_CONSUMER, consistent with the behavior of
resolveAndReadParentExternally().

Fixes #11798

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
gnodet added a commit that referenced this pull request Jun 17, 2026
#12286)

Backport of #11799 to maven-4.0.x.

Ensure readParentLocally() uses CONSUMER_PARENT when the current request is BUILD_CONSUMER, consistent with resolveAndReadParentExternally().

Fixes #11798
@gnodet gnodet added the bug Something isn't working label Jun 23, 2026
gnodet added a commit that referenced this pull request Sep 1, 2026
…tifactId

Add unit tests and integration test verifying that the consumer POM
builder correctly handles OS-activated profile properties used in
dependency artifactId coordinates. This scenario (from Apache Hop)
is already handled by the CONSUMER_PARENT request type (#11799)
and the MNG-8709 user-property fix, but had no regression test.

Unit tests cover:
- BUILD_CONSUMER resolving parent profile properties in artifactId
- BUILD_CONSUMER after BUILD_PROJECT (cache hit scenario)
- OS-activated profile properties with full reactor simulation

Integration test covers:
- Multi-module project with OS-activated profiles in parent POM
- Dependency management entries inside profiles using ${...} artifactId
- Non-flattened consumer POM preserving parent and profiles
- Flattened consumer POM fully resolving the property

Closes #13004

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit that referenced this pull request Sep 2, 2026
…tifactId

Add unit tests and integration test verifying that the consumer POM
builder correctly handles OS-activated profile properties used in
dependency artifactId coordinates. This scenario (from Apache Hop)
is already handled by the CONSUMER_PARENT request type (#11799)
and the MNG-8709 user-property fix, but had no regression test.

Unit tests cover:
- BUILD_CONSUMER resolving parent profile properties in artifactId
- BUILD_CONSUMER after BUILD_PROJECT (cache hit scenario)
- OS-activated profile properties with full reactor simulation

Integration test covers:
- Multi-module project with OS-activated profiles in parent POM
- Dependency management entries inside profiles using ${...} artifactId
- Non-flattened consumer POM preserving parent and profiles
- Flattened consumer POM fully resolving the property

Closes #13004

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.

Maven 4 (rc5) fails in maven-install-plugin due to BUILD_CONSUMER disabling profile activation for locally-resolved parent POMs

2 participants