Repository navigation
Fix #13100: honor repositories from legitimately-active external model profiles - #13155
Conversation
…l model profiles Backport of apache#13141 (master) and apache#13116 (maven-3.10.x) to maven-4.0.x. The withoutRepositories() stripping (compat stack) and the .map() stripping (impl stack) were applied to all active profiles in the externalOrigin branch unconditionally — regardless of why they activated. The hasFileOrPropertyOrConditionActivation filter already suppresses file- and property-activated profiles before they reach injection. The blanket strip was therefore over-broad: it discarded repositories from legitimately-active profiles (JDK/OS, activeByDefault) with no security benefit, breaking the established pattern where a dependency POM declares a non-Central repository inside a JDK- or activeByDefault-activated profile. Changes: - compat: remove withoutRepositories() call from the profile injection loop; remove the now-dead withoutRepositories() helper method; add TODO(apache#13146) - impl: remove .map() repository stripping from the externalOrigin branch; update comment; add TODO(apache#13146) - tests: flip noneMatch → anyMatch for all externalOrigin=true assertions; add testActiveByDefaultProfileRepositoryHonored() with isolated fixture; rename testDependencyPomActivatesOnlyEnvironmentIndependentProfiles BUILD_CONSUMER stripping is intentional and unchanged.
gnodet-bot
left a comment
There was a problem hiding this comment.
The fix is logically correct: hasFileOrPropertyOrConditionActivation already gates out file/property/condition profiles before getActiveProfiles, so only JDK, OS, and activeByDefault profiles reach the injection loop — removing the blanket repo-strip from those is the right call. The BUILD_CONSUMER branch correctly continues to strip, the TODO(#13146) acknowledgement of the URL-shadow concern is appropriate, and the test isolation rationale is sound.
Two issues to fix before merge:
-
Stale class-level Javadoc —
ExternalModelProfileActivationTest(compat): The class doc still reads "their profiles contribute no repositories" (line 34). That's now false for JDK/OS/activeByDefault-activated profiles — the very profiles this PR re-enables. Should be updated to reflect the new contract: file and property profiles contribute no repositories; legitimately-active (JDK/OS/activeByDefault) profiles do contribute their repositories. -
Stale class-level Javadoc —
DefaultModelBuilderTest(impl): Same stale sentence at line 128 of that file. -
GAV typo in
testActiveByDefaultProfileRepositoryHonored(impl):Sources.resolvedSource(..., "org.apache.maven.**test**:active-by-default-profile:1.0.0")— should beorg.apache.maven.**tests**(plural) to match the fixture's declared<groupId>. The hint string doesn't affect profile evaluation, so the test passes regardless, but the inconsistency is confusing.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| .session(session) | ||
| .requestType(ModelBuilderRequest.RequestType.CONSUMER_DEPENDENCY) | ||
| .source(Sources.resolvedSource( | ||
| getPom("active-by-default-profile"), "org.apache.maven.test:active-by-default-profile:1.0.0")) |
There was a problem hiding this comment.
org.apache.maven.test (singular) does not match the fixture's <groupId>org.apache.maven.tests</groupId> (plural). The coordinate hint passed to resolvedSource does not drive profile selection, so the test still passes — but readers will be confused when they cross-reference the fixture. Please fix to "org.apache.maven.tests:active-by-default-profile:1.0.0".
| getPom("active-by-default-profile"), "org.apache.maven.test:active-by-default-profile:1.0.0")) | |
| getPom("active-by-default-profile"), "org.apache.maven.tests:active-by-default-profile:1.0.0")) |
| limitations under the License. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.1.0"> | ||
| <groupId>org.apache.maven.tests</groupId> |
There was a problem hiding this comment.
For consistency with the rest of the poms/factory/ fixtures and with how the impl test references this artifact, consider using org.apache.maven.test (without the trailing s) — or conversely, update the resolvedSource call to say org.apache.maven.tests. Either is fine; they just need to match.
- DefaultModelBuilderTest: update resolvedProfilesRequest() Javadoc (stale 'contribute no repositories'); fix active-by-default-profile resolvedSource GAV (org.apache.maven.test, matching fixture and existing test convention) - active-by-default-profile.xml: fix groupId plural→singular to match the rest of the poms/factory fixtures and the test coordinate hint - ExternalModelProfileActivationTest: update class-level Javadoc (stale 'contribute no repositories') Found during review of apache#13155.
gnodet-bot
left a comment
There was a problem hiding this comment.
All three findings from the prior review are addressed in the fixup commit (8011ebaf):
- ✅ Stale Javadoc —
ExternalModelProfileActivationTest(compat): class-level doc updated to reflect that legitimately-active profiles (JDK/OS/activeByDefault) do contribute repositories. - ✅ Stale Javadoc —
DefaultModelBuilderTest(impl): same stale sentence corrected with the same contract description. - ✅ GAV groupId typo: fixture
<groupId>corrected fromorg.apache.maven.tests→org.apache.maven.test, matching theresolvedSourcecoordinate in the test.
No new issues found. CI is fully green across all 22 matrix jobs (JDK 17/21/25, Ubuntu/macOS/Windows, unit + ITs). The fix is correct: VALIDATION_LEVEL_MINIMAL < VALIDATION_LEVEL_MAVEN_2_0 reliably exercises the externalModel=true branch, and BUILD_CONSUMER stripping is correctly left intact.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
…#13141) (#13156) * Fix stale Javadoc and GAV typo in external-profile tests - DefaultModelBuilderTest: update resolvedProfilesRequest() Javadoc (stale 'contribute no repositories'); fix active-by-default-profile resolvedSource GAV (org.apache.maven.test, matching fixture and existing test convention) - active-by-default-profile.xml: fix groupId plural→singular to match the rest of the poms/factory fixtures and the test coordinate hint Found during review of #13155. * Revert wrong direction: keep org.apache.maven.test (no 's') in resolvedSource
Backport of #13141 (master) and #13116 (maven-3.10.x) to
maven-4.0.x.Problem
The
withoutRepositories()stripping (compat stack) and the.map()stripping (impl stack) were applied to all active profiles in theexternalOriginbranch unconditionally — regardless of why they activated.The
hasFileOrPropertyOrConditionActivationfilter already suppresses file- and property-activated profiles before they reach injection. The blanket strip was therefore over-broad: it discarded repositories from legitimately-active profiles (JDK/OS,activeByDefault) with no security benefit, breaking the established pattern:where
dep1declaresdep2's non-Central repository inside a JDK- oractiveByDefault-activated profile.Changes
maven-model-builder): removewithoutRepositories()call from the profile injection loop; remove the now-deadwithoutRepositories()helper method; addTODO(#13146)maven-impl): remove.map()repository stripping from theexternalOriginbranch; update comment; addTODO(#13146)noneMatch → anyMatchfor allexternalOrigin=trueassertions; addtestActiveByDefaultProfileRepositoryHonored()with isolated fixture; renametestDependencyPomActivatesOnlyEnvironmentIndependentProfilesBUILD_CONSUMERstripping is intentional and unchanged — consumer POMs must not leak profile repositories into the published artifact.Notes
centralwith a different URL) is orthogonal and should be addressed separately as a WARN/FAIL policy — see [MNG] Warn or fail when an external-model profile repository shadows central #13146.