Repository navigation
Cascading profile activation - #1774
Conversation
21eb346 to
1ed072b
Compare
3f184eb to
3d21d5f
Compare
9d59fbc to
a5a3941
Compare
a5a3941 to
c7edd16
Compare
4b18472 to
3dfcd05
Compare
cd869f3 to
b4ba025
Compare
|
Is this whole PR only about cascading profile activation? There are mvnup changes for example... |
Reviewed 3 PRs: apache#982 (PowerShell 3.9.x, syntax bugs), apache#878 (PowerShell master, needs Maven 4 rewrite), #33 (qualityManagement, oldest PR at 11 years). 45 reviews posted total. Only 3 truly unreviewed PRs remain: apache#2277, apache#1774, #71 (all large). Co-Authored-By: Claude Opus 4.6 <[email protected]>
gnodet
left a comment
There was a problem hiding this comment.
AI Review — PR #1774: [MNG-3309] Cascading profile activation
This PR implements cascading profile activation — a long-requested feature where activating one profile can trigger activation of another via properties set by the first. The core design is sound (the loop terminates correctly), but there are several issues to address.
Bug
ReportSet merge result discarded — In MavenModelMerger.java, the change from:
element = mergeReportSet(element, existing, sourceDominant, context);to:
mergeReportSet(element, existing, sourceDominant, context);discards the merged result. In the Maven 4 immutable model, mergeReportSet returns a new object via builder.build() — it does not mutate in place. The original unmerged element is put into the map, silently breaking ReportSet merging during inheritance. (The compat ModelMerger uses void returns, so this may have been copied from the wrong pattern.)
Correctness Concerns
1. NPE in ConditionProfileActivator — doGetProperty(Profile profile, ...) calls Profile.SOURCE_POM.equals(profile.getSource()) but ConditionParserTest passes null as the profile parameter. If any property resolution reaches the model-property fallback path, this will NPE. Current tests don't trigger it (they resolve system properties), but the code is fragile.
2. instanceof coupling for cascading API — addProfileProperties was correctly added to the ProfileActivationContext interface, but clearCascadedProfileProperties() and getModelPropertyForActivation() are only on DefaultProfileActivationContext and accessed via instanceof downcasts (4 places). Alternative implementations won't crash (they fall back), but the asymmetry is a code smell.
Behavioral Changes
- CI-friendly parent version support removed — The deleted
MavenITgh12184CIFriendlyParentVersionTestconfirms${revision}in parent version is no longer handled the same way. This needs migration guide documentation. - Repository validation upgraded WARNING → ERROR — Uninterpolated expressions in repository id/url now fail the build instead of warning. May break real-world builds.
- Property lookup order changed —
ConditionProfileActivator.doGetPropertynow checks user → system → model (previously user → model → system). System properties now take precedence over model properties during activation.
Scope Concern
As committer cstamas noted, this PR bundles many unrelated changes (mvnup fixes, plugin version changes, consumer POM simplification, GitHub Actions downgrades) with the cascading activation feature. Splitting into focused PRs would improve reviewability.
What Works Well
The cascading activation core design is correct: the do...while loop removes activated profiles from remainingProfiles on each iteration, guaranteeing monotonic progress and termination. Circular dependencies are handled correctly (both profiles activate in the first pass). Test coverage for the cascading behavior is adequate.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
Reviewed final 3 PRs: apache#2277 (modernize codebase), apache#1774 (cascading profiles, found ReportSet merge bug), #71 (mirrors in profiles). 48 reviews posted total. All 61 open PRs have now been reviewed or skipped. Co-Authored-By: Claude Opus 4.6 <[email protected]>
gnodet
left a comment
There was a problem hiding this comment.
Code Review
The cascading profile activation feature (MNG-3309) is well-designed — the core mechanism in DefaultProfileSelector has proper termination (profiles removed from the remaining set after activation, guaranteeing at most N iterations). However, the PR carries a single squashed commit rebased onto master that actively reverses at least five recently-merged bug fixes:
-
targetPath alignment reversion (
DefaultModelPathTranslator.java:137): Reverts commit dac6ab1 — re-introduces the bug whereSource.targetPath(relative to output directory) is incorrectly resolved against project basedir. The associated tests (DefaultModelPathTranslatorTest,ProjectBuilderTestassertions) are also deleted. -
Consumer POM settings.xml repos reversion (
DefaultConsumerPomBuilder.java:303): Reverts commit 3656bff — removes repository/profile passing from the execution request to the model builder. Users with corporate/private repository BOMs defined insettings.xmlwill hit "Non-resolvable import POM" errors during consumer POM building. TestMavenITConsumerPomBomFromSettingsRepoTestis deleted. -
CI-friendly version interpolation reversion (
DefaultModelBuilder.java:734): Reverts commit 55ee0a3 — changes fromrequest.getSystemProperties()+request.getUserProperties()back tosession.getEffectiveProperties(). When user properties on the ModelBuilderRequest differ from the Session (e.g.,-Drevision=2.0.0), interpolation becomes inconsistent. TestMavenITgh12184CIFriendlyParentVersionTestis deleted. -
versionContainsExpression removal (
DefaultModelBuilder.java:1584): Removes the special handling for parent versions containing${...}expressions (like${revision}) for CI-friendly parent resolution. This code was merged to master after the branch's merge base, so it's a stale-branch gap rather than an active reversion, but the regression impact is the same. -
Exception handler HTTPS check reversion (
DefaultExceptionHandler.java:207): Reverts commit b404258 — removes the!reference.startsWith("https:")guard, causing HTTPS reference URLs to get incorrectly prepended with the cwiki URL. Also removes theArtifactFilteredOutExceptionhandling that provided user-friendly guidance.
These are most likely merge conflict resolution artifacts from the rebase that chose the branch's pre-fix version of shared files. They should be resolved by cherry-picking the fixes into the feature branch or re-resolving conflicts.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
b4ba025 to
f32e5c8
Compare
|
Rebased onto current `master` (as of 2026-09-23). Conflicts resolved during rebase:
Full |
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review — PR #1774: [MNG-3309] Cascading profile activation
This rebase is a significant improvement over the previous iterations: the unrelated changes and regression reverts that prior reviews flagged are gone. The PR is now cleanly scoped to the cascading feature. Good. However, there are three issues that still need to be resolved.
Status of prior findings:
- Scope/revert issues → ✅ Resolved by this rebase
- ReportSet merge bug → ✅ Not present in this diff
- NPE in
ConditionProfileActivator.doGetPropertywhenprofile == null→ ❌ Still present (see below) instanceofcoupling → acknowledged, partially acceptable, but introduces a new variant of the problem (see below)
This review was generated by an AI agent, Hermès on behalf of @gnodet.
f32e5c8 to
69e3683
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Thanks for this cascading profile activation implementation — the idea is sound and the test coverage is solid. A few issues need to be addressed before this can merge.
Critical:
- SPI break:
addProfilePropertiesis added toProfileActivationContextwithout adefaultimplementation, breaking all existing custom implementors. - NPE:
ConditionProfileActivator.doGetPropertyis called withprofile=nullfromConditionParserTest, butProfile.SOURCE_POM.equals(profile.getSource())will throw. - Behavioral regression:
activeByDefaultprofiles are temporarily added toactivatedProfilesand their properties injected viaaddProfileProperties, but they are later potentially dropped from the final result — spurious property injection.
Design:
4–6. instanceof DefaultProfileActivationContext appears in three separate places. This hard-wires the cascading mechanism to the default implementation and silently breaks for custom SPI implementations.
7. Property lookup order changed from user→model→system to user→system→model in ConditionProfileActivator without documentation of the intentional semantic shift.
8. interpolatePath now resolves file-existence activation paths against cascaded properties — unintended side-effect.
Housekeeping:
9. New test resource POM (cascading-profile-activation/pom.xml in maven-core) has no referencing test class.
10. DefaultProfileSelectorTest duplicates the instanceof coupling in its inner PropertyProfileActivator.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
69e3683 to
749bfa4
Compare
749bfa4 to
826aa00
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — 7 of the 10 findings are fully addressed in this iteration; 2 remain open and I've found 1 new issue.
Resolved ✅:
- SPI break (
addProfilePropertiesmissingdefault) — fixed, no-op default added to interface instanceofcoupling onclearCascadedProfileProperties()— SPI default method nowinstanceofcoupling ongetCascadedProfileProperty()in both activators — SPI method now- NPE when
profileis null inConditionProfileActivator— null guard added - Undocumented property lookup order change — Javadoc comment added to
doGetProperty activeByDefaultspurious injection —activeByDefaultprofiles correctly excluded fromactivatedProfileslist- Orphaned test resource (
maven-core/cascading-profile-activation/pom.xml) — removed
Still open / new issues below.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
826aa00 to
3d630fa
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — the visibility fix (getModelPropertyForActivation now private) and the inner-class coupling in the test are both resolved. One correctness bug and one missing test still need addressing.
Resolved ✅:
getModelPropertyForActivationvisibility — nowprivate✅DefaultProfileSelectorTestinnerPropertyProfileActivatorclass — test now uses the real production class ✅
Still open / new issue below.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
3d630fa to
e3bb800
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — the path interpolation lookup order is fixed ✅. One finding remains.
Resolved ✅:
- Path interpolation lookup order in
interpolate()— now correctlyuser → system → cascaded/model, matching the documented precedence ✅
Still open:
- Missing test for file-existence cascade behavior (see inline comment below)
This review was generated by an AI agent, Hermès on behalf of @gnodet.
e3bb800 to
d7ebd71
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
All prior concerns are resolved. The cascading profile activation implementation is correct and well-tested:
- Loop termination: The
remainingProfilespool strictly shrinks on every iteration — bounded termination guaranteed. - Explicit activation excluded from cascading: Profiles activated via
-PoractiveByDefaultare removed fromremainingProfilesbut not added toactivatedProfiles, so they don't trigger cascades.testExplicitlyActivatedProfileDoesNotCascadevalidates this. - Interpolation order corrected:
user → system → cascaded/modelnow matchesConditionProfileActivator.doGetProperty, fixing the previous instability. - Settings profiles guarded: Both
ConditionProfileActivatorandPropertyProfileActivatorgate cascaded property lookup onSOURCE_POM, preventing settings profiles from participating. - Sandboxed context safe:
addProfilePropertiesis a no-op,getCascadedProfilePropertyreturns null — no cascading leakage into external/dependency model resolution. - SPI backward compatible: All three new methods have
defaultimplementations.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Cascading profile activation allows a profile to set a property that immediately triggers the activation of subsequent profiles within the same POM. Implementation: - DefaultProfileSelector now iterates profile activation in a loop until stable - Cascaded properties are stored in a separate map (DefaultProfileActivationContext) isolated from main model properties to avoid interference with settings profiles - Model properties (including cascaded ones) are only consulted for POM profile activation (Profile.SOURCE_POM), never for settings profiles — prevents cascaded properties from overriding Maven system properties that affect repository resolution - Property priority: user properties > system properties > model properties (POM only) - Cascaded properties are cleared after each activation round The full IT suite (1034 tests) passes locally.
d7ebd71 to
c729bdb
Compare
# Conflicts: # impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultProfileActivationContext.java
…operties After merging apache#13555, start(Map) no longer exposes parent POM properties through getModelProperty(). The profile.pom.condition assertion expected the parent's declared property to self-activate a condition-based profile, which contradicts apache#13390's design intent. This aligns with apache#13556 on master. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — the previous APPROVE was given at commit d7ebd71 (2026-10-16). Since then, three commits were added:
- Merge from master (2026-10-19)
fix: remove pom.condition assertion(2026-10-20)docs: document cascading profile activation(2026-10-20)
The master merge silently removed the cascading activation mechanism that was the core of this PR. The new commits do not account for this regression.
The merge from master (commit 46532a35, 2026-10-19) brought in changes that completely removed the cascading mechanism:
DefaultProfileSelector.getActiveProfiles()is now a simple single-pass loop — thedo { ... } while (!activatedProfiles.isEmpty())cascading loop is gone.ProfileActivationContextSPI no longer exposesaddProfileProperties(),getCascadedProfileProperty(), orclearCascadedProfileProperties()— the cascade injection contract was removed entirely.ConditionProfileActivator.doGetProperty()no longer callscontext.getCascadedProfileProperty()— the cascaded lookup was stripped out.PropertyProfileActivatorno longer checks cascaded properties.DefaultProfileSelectorTest— which hadtestCascadingActivation(),testCascadingActivationChain(),testCascadingWithCircularDependency(), and 12 other cascading-specific tests — was deleted entirely.
The IT test MavenITmng3309CascadingProfileActivationTest will now fail. It expects profile step1 to activate because profile trigger sets cascade.step1=activated, and profile step2 to activate because step1 sets cascade.step2=activated. None of this works anymore: during profile activation, context.getModelProperty("cascade.step1") returns null (it's not in the POM's <properties> block — it was only set by profile trigger at injection time, after activation). Without the cascading loop, profile step1 and step2 never see these properties and remain inactive.
The new documentation in maven.mdo ("When a profile is activated and defines properties, those properties are immediately available to trigger the activation of other profiles") is now inaccurate — this is no longer how Maven works after the master merge.
Required action: The PR needs to resolve the conflict between the master merge's removal of the cascading mechanism and the PR's core feature. Either:
- Restore the cascading loop in
DefaultProfileSelector(and the SPI methods, and the cascade lookups in activators) — rebasing the PR's cascading changes on top of master rather than letting the merge overwrite them; or - If the cascading approach was intentionally replaced, update the PR description, docs, IT tests, and test assertions to reflect the new design.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — the previous REQUEST_CHANGES (2026-10-20, SHA 8ddbcea) was based on an incorrect reading of the master merge: the cascading mechanism was NOT removed. The cascading loop, SPI methods, and cascade lookups in both activators are all present and correct. That review is retracted.
Status of the 4 commits since the Oct 16 APPROVE:
46532a35(master merge) — Correctly integratesinterpolationPropertiesfrom #13555 alongsidecascadedProfileProperties. Both fields coexist without conflict. ✅a06ea974(fix: remove pom.condition assertion) — Necessary and correct: after #13555,start(Map)stores parent POM properties ininterpolationProperties(path interpolation only), not in the model returned bygetModelProperty(). The oldassertEquals("activated", ...)assertion was testing behavior that #13390 explicitly prohibits — its removal is correct. ✅8ddbcea(docs: document cascading profile activation) — Documentation inmaven.mdoaccurately describes the implementation: POM-profiles-only guard, property precedence (user → system → cascaded), and fixed-point iteration. ✅d569af2(test: add negative assertion for profile.pom.condition in project-parent path) — Locks in real behavior: after #13555,getModelProperty()returns null for parent POM properties in the project-parent activation path, soprofile.pom.conditioncorrectly does not self-activate. TheassertNullassertion is correct and exercises the actual code path. ✅
All prior concerns resolved. LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
@gnodet Please assign appropriate label to PR according to the type of change. |
…es it Commit 651d7a5 (in this branch) restored model.withProperties(interpolationProperties) in start(Map) so that POM-property conditions could fire in project-parent paths. This is now incorrect: PR apache#1774 (Cascading profile activation, commit 9e7a17e) landed in master and provides the proper mechanism: POM properties from activated profiles flow through getCascadedProfileProperty(), not getModelProperty(). The cascading PR also updated testResolvedDependencyParentCacheDoesNotShareActivationWithProjectParent to assert that profile.pom.condition must NOT self-activate even in the project-parent path (assertNull at line 381-383), which conflicts with what 651d7a5 introduced. Revert start(Map) to pass the original model (not model.withProperties(...)). Path interpolation is unaffected — interpolationProperties is still passed separately and used exclusively inside interpolate() for placeholder resolution (see apache#10375). The fix for apache#13390 remains intact.
…14069) * [Backport maven-4.0.x] #12377: Remove Profile getSource / setSource Backport of #12377 to maven-4.0.x. - Replace Profile.SOURCE_POM.equals(profile.getSource()) with isFromPom() using InputLocation/InputSource detection in DefaultProfileSelector, ConditionProfileActivator, and PropertyProfileActivator - Add ProfileSourceDetector utility class - Fix 4.0.0/4.0.99 compat segment to use own field instead of delegate - Note: cascading profile activation (from #1774) not backported; cascading-specific tests disabled with @disabled Cherry-picked from b0da053 * Address review: remove dead isFromPom() wrappers, fix @SInCE tag * fix: remove trailing blank lines (Spotless) * fix: schema codeSegment blocks - 4.0.0/4.0.99 keeps getSource/setSource, 4.1.0+ has clean toString only --------- Co-authored-by: Guillaume Nodet <[email protected]>
Fixes #4637
Why
Maven profiles can be activated by properties, but there is no way for one profile's
properties to trigger another profile's activation within the same POM. Users who want
a "default" profile that enables a set of other profiles must resort to workarounds like
external scripts, wrapper POMs, or duplicating activation conditions. This has been a
long-standing request (JIRA MNG-3309, opened in 2007).
What
This PR implements cascading profile activation: when a profile activates and
defines properties, those properties are immediately available to trigger the activation
of subsequent profiles in the same POM. The mechanism iterates until no new profiles
activate (fixed-point).
Example — profile
defaultsetsenable.checks=true, which cascades to activaterun-checkstyleandrun-spotbugs:How
ProfileActivationContextSPI (backward-compatibledefaultmethods):addProfileProperties(Collection<Profile>)— injects properties from newly activatedprofiles into the cascading context
getCascadedProfileProperty(String)— retrieves cascaded properties only (not thePOM's own
<properties>)clearCascadedProfileProperties()— cleans up after activation completesDefaultProfileSelectoriterates activation in a loop until stable. Onlyauto-activated profiles (matching an activator condition) cascade — explicitly activated
profiles (
-Pflag) andactiveByDefaultprofiles do not inject properties into thecascade, preventing unintended side effects.
ConditionProfileActivatorresolves cascaded properties (then model properties) forPOM profiles. Property lookup order: user → system → cascaded → model.
PropertyProfileActivatoralso checks cascaded properties for POM profiles, usingthe same user → system → cascaded order (without model property fallback, so a POM's own
<properties>cannot self-activate<property>-based profiles).Safeguards:
settings profiles
Profile.SOURCE_POM) consult cascaded/model properties — settingsprofiles never do
interpolatePathuses user → system → model order so user-Dflags always wininstanceofcoupling — activators use the SPI methods directly🤖 Generated with Claude Code