Repository navigation
Fix/13390 dependency profile property activation - #13401
Utkarsh-rwt wants to merge 6 commits into
Conversation
Prevent dependency POM-local properties from activating their own profiles while preserving external model sandbox behavior and negated default-on profiles. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit cb05133. revert
This comment has been minimized.
This comment has been minimized.
gnodet
left a comment
There was a problem hiding this comment.
Two findings on this PR.
Metadata suggestions
- Milestone: 4.1.0
- Backport to
maven-3.10.x:⚠️ Missing — the compat-layer behavioral change likely needs a matching backport.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| mergedSystemProperties = Collections.unmodifiableMap(merged); | ||
| } | ||
| return mergedSystemProperties; | ||
| return delegate.getSystemProperties(); |
There was a problem hiding this comment.
externalActivationContext() previously merged POM <properties> into the system-properties map so that property-based profiles in dependency POMs could still fire. This PR removes that merging: getSystemProperties() now delegates directly, stripping POM-declared properties from the sandbox entirely.
That is an intentional behaviour reversal in the compat layer (compat/maven-model-builder). The compat layer is supposed to mirror Maven 3 semantics as closely as possible. If maven-3.10.x still carries the old merging logic, this change should be backported there too — or the PR should explicitly justify why the compat-layer behaviour intentionally diverges from Maven 3.
| // profiles (JDK/OS/activeByDefault and negated-property default-on profiles) | ||
| // reach injection, |
There was a problem hiding this comment.
💬 Minor: Awkward comment wrapping — "reach injection," dangles
The new lines read:
// profiles (JDK/OS/activeByDefault and negated-property default-on profiles)
// reach injection,
// and stripping their repositories would break the established
// reach injection, is a dangling continuation, making the sentence hard to parse. Consider collapsing the two lines:
| // profiles (JDK/OS/activeByDefault and negated-property default-on profiles) | |
| // reach injection, | |
| // profiles (JDK/OS/activeByDefault and negated-property default-on profiles) | |
| // reach injection, and stripping their repositories would break the established |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for pointing this out. I confirmed that maven-3.10.x still contains the same compat-layer behavior and therefore needs the fix as well. I will keep this PR targeted at Maven 4.1.0 and prepare a separate backport PR against maven-3.10.x, including the compat implementation and regression test. |
gnodet
left a comment
There was a problem hiding this comment.
Re-reviewing after the clarification commit.
The backport concern raised in the previous review (compat-layer behavioural change in maven-3.10.x) remains unanswered — please address it or explicitly document why the compat layer should diverge from Maven 3 semantics.
Metadata suggestions
- Milestone: 4.1.1
- Backport to
maven-3.10.x:⚠️ Still missing —origin/maven-3.10.xcarries the merging logic at lines 544–551 in the compatDefaultModelBuilder.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Prevent dependency POM-local properties from reaching external condition activation and add regression coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I agree the external sandbox must prevent dependency POM-local properties from influencing both property-based and condition-based profile activation. Updated in commit e11d322:
Validation passed:
I will also address the remaining Maven 3.10.x compat-layer backport separately. |
gnodet
left a comment
There was a problem hiding this comment.
Re-review of commit e11d322.
The getModelProperty() sandbox gap is confirmed closed — the new commit makes it return null in the DefaultProfileActivationContext sandbox, so POM-declared properties cannot drive condition expressions via ConditionProfileActivator. ✅
Two prior findings remain unaddressed:
-
Dangling comment wrap (line 1665–1666 below) — the
// reach injection,continuation hangs on its own line; prior suggestion still not applied. -
Backport to
maven-3.10.xstill missing — thecompat/maven-model-builderbehavioral change (removing POM property merging from the system-property sandbox) diverges frommaven-3.10.x. Author acknowledged the gap and committed to a backport PR, but it hasn't appeared. Please prepare the backport before or alongside this PR merging.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| // profiles (JDK/OS/activeByDefault and negated-property default-on profiles) | ||
| // reach injection, and stripping their repositories would break the established |
There was a problem hiding this comment.
Dangling comment continuation — // reach injection, wraps to its own line, making the sentence awkward to parse. Prior suggestion still not applied.
| // profiles (JDK/OS/activeByDefault and negated-property default-on profiles) | |
| // reach injection, and stripping their repositories would break the established | |
| // profiles (JDK/OS/activeByDefault and negated-property default-on profiles) reach injection, | |
| // and stripping their repositories would break the established |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gnodet
left a comment
There was a problem hiding this comment.
The PR fixes the property-based profile activation regression in master, but a backport to maven-3.10.x is missing.
Issue #13390 explicitly states:
The behavior is still present in maven-3.10.x.
The fix targets compat/maven-model-builder and impl/maven-impl on master only. No corresponding maven-3.10.x PR has appeared. The author acknowledged this gap in prior comments ("I confirmed that maven-3.10.x still contains the same compat-layer behavior and therefore needs the fix as well") but the backport has not been submitted yet.
Please submit a companion PR targeting maven-3.10.x before this is merged, or confirm the branch policy that makes a backport unnecessary.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
The companion Maven 3.10.x backport has now been submitted: It targets The backport also updates the regression test:
Validation passed: |
|
Fully automatic review from Claude Code Closing in favor of #13450 (master), #13451 (maven-3.10.x), and #13452 (maven-4.0.x), which address the same issue with equivalent changes plus updated Javadoc across all interfaces and additional regression tests (jruby-style #13390 and resteasy-style #13084 non-regression). Thank you for working on this — the analysis in the PR description is solid. |
Summary
Note : copilot helped me to write this pr
Fixes #13390.
This change prevents properties declared in a dependency POM from activating property-based profiles in that same POM during external model building.
Background
Maven 3.10.0 introduced external dependency-POM profile hardening through the changes for #13084, implemented in #13112 and backported through #13114.
That change introduced an external
ProfileActivationContextwhich suppressed consumer user properties and merged the dependency model's project properties into the system-property lookup.The merge caused a dependency POM such as:
to activate its own property-based profile:
POM-defined properties should not act as profile activation properties for the same dependency POM.
Scope
This PR addresses the POM-local property activation bug from #13390.
It does not change the intentional external-model hardening for file-based profiles, and it does not address the separate compatibility question from #13347 regarding whether
-Dmaven.model.dependencyInterpolation.full=trueshould restore user-property profile activation.Changes
java.versionandos.name.-D) when evaluating dependency POM profiles.!resteasy.dependencies.eappattern.compat/maven-model-builderimpl/maven-implTests
Updated and added regression coverage in both model-building implementations.
Compat model builder
Updated:
compat/maven-model-builder/src/test/java/org/apache/maven/model/building/ExternalModelProfileActivationTest.javaThe tests verify that:
<properties>remains inactive.Maven implementation model builder
Updated:
impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultModelBuilderTest.javaAdded an assertion that a dependency POM's declared property does not activate its own profile.
Updated:
impl/maven-impl/src/test/resources/poms/factory/resolved-model-with-profiles.xmlAdded a POM-local property and a profile activated by that property to reproduce #13390.
Validation
The full reactor command was executed:
mvn -DdistributionTargetDir="$PWD/target/apache-maven-test-dist" clean verifyThe full reactor reached
maven-core, but failed in four unrelated existingProjectModelResolverTestcases because the test repository returned no matching versions for ranges such as(,2.0)and[1,).The affected tests were run independently:
mvn -pl compat/maven-model-builder,impl/maven-impl \ -Dtest=ExternalModelProfileActivationTest,DefaultModelBuilderTest \ -Dsurefire.failIfNoSpecifiedTests=false testResult:
impl/maven-impl:DefaultModelBuilderTest— 40 passedcompat/maven-model-builder:DefaultModelBuilderTest— 3 passedcompat/maven-model-builder:ExternalModelProfileActivationTest— 10 passed