[MNG-8709] Use active profile properties for consumer POM validation - #12684
[MNG-8709] Use active profile properties for consumer POM validation#12684goutamadwant wants to merge 1 commit into
Conversation
Use properties from profiles already active in the built project when validating the consumer model. Preserve user-property precedence and keep the generated consumer POM profile-backed. Add a Core IT for dependency versions supplied by an active-by-default profile.
gnodet
left a comment
There was a problem hiding this comment.
The code change is correct and well-motivated. The fix properly injects active profile properties as user properties during consumer POM rebuild, with correct precedence (session user properties override via putAll afterward). The inline comment at the injection site clearly documents the intent.
The integration test (MavenITmng8709ProfileDependencyVersionTest) covers the end-to-end scenario well — verifying both that install succeeds and that the consumer POM retains the profile definition with the property expression.
Non-blocking suggestion: Consider adding a unit test in ConsumerPomBuilderTest following the existing spy pattern from testConsumerPomPassesProjectRepositoriesToModelBuilder — set active profiles with properties on the MavenProject and verify the captured BUILD_CONSUMER request's userProperties contain the profile properties. This would provide faster feedback alongside the integration test.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
Fixes #10379.
When Maven rebuilds a consumer POM,
BUILD_CONSUMERdoes not reactivate the profiles that were active while building the project. As a result, model validation can see unresolved dependency versions when their values come from an active profile.This change makes properties from the project's already-active profiles available while rebuilding the consumer model. Session user properties are applied afterward so their existing precedence is preserved. The change does not activate additional profiles or replace profile-backed expressions in the generated consumer POM.
A Core IT covers an
activeByDefaultprofile that supplies a dependency version and verifies that installation succeeds while the generated consumer POM retains both the profile and the property expression.Tests
mvn -pl impl/maven-core -Dtest=ConsumerPomBuilderTest testmvn -Prun-its -DmavenHome=<maven-under-test> -Dtest=MavenITmng8709ProfileDependencyVersionTest -Dsurefire.failIfNoSpecifiedTests=false verifymvn -Prun-its -DmavenHome=<maven-under-test> verify -rf :core-it-suiteon JDK 21https://repo1.maven.orgwhile the local environment usedhttps://repo.maven.apache.org.Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
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.