Skip to content

[MNG-8709] Use active profile properties for consumer POM validation - #12684

Open
goutamadwant wants to merge 1 commit into
apache:maven-4.0.xfrom
goutamadwant:fix-profile-property-consumer-pom
Open

[MNG-8709] Use active profile properties for consumer POM validation#12684
goutamadwant wants to merge 1 commit into
apache:maven-4.0.xfrom
goutamadwant:fix-profile-property-consumer-pom

Conversation

@goutamadwant

Copy link
Copy Markdown

Fixes #10379.

When Maven rebuilds a consumer POM, BUILD_CONSUMER does 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 activeByDefault profile 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 test
  • mvn -Prun-its -DmavenHome=<maven-under-test> -Dtest=MavenITmng8709ProfileDependencyVersionTest -Dsurefire.failIfNoSpecifiedTests=false verify
  • mvn -Prun-its -DmavenHome=<maven-under-test> verify -rf :core-it-suite on JDK 21
    • 1,037 tests ran and the MNG-8709 regression passed. One unrelated existing test failed because it expected the legacy Central URL https://repo1.maven.org while the local environment used https://repo.maven.apache.org.

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.

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 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 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

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.

2 participants