Skip to content

[MNG-3309] Cascading profile activation#1774

Open
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:cascading-profile-activation
Open

[MNG-3309] Cascading profile activation#1774
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:cascading-profile-activation

Conversation

@gnodet

@gnodet gnodet commented Oct 4, 2024

Copy link
Copy Markdown
Contributor

@gnodet gnodet added this to the 4.0.0-beta-5 milestone Oct 4, 2024
@gnodet gnodet force-pushed the cascading-profile-activation branch from 21eb346 to 1ed072b Compare October 4, 2024 20:05
@gnodet gnodet modified the milestones: 4.0.0-beta-5, 4.1.0 Oct 7, 2024
@gnodet gnodet force-pushed the cascading-profile-activation branch 2 times, most recently from 3f184eb to 3d21d5f Compare October 25, 2024 20:36
@gnodet gnodet marked this pull request as draft November 20, 2024 20:39
@gnodet gnodet force-pushed the cascading-profile-activation branch from 9d59fbc to a5a3941 Compare July 4, 2025 07:49
@gnodet gnodet marked this pull request as ready for review July 4, 2025 07:50
@gnodet gnodet force-pushed the cascading-profile-activation branch from a5a3941 to c7edd16 Compare October 9, 2025 07:25
@gnodet gnodet force-pushed the cascading-profile-activation branch 5 times, most recently from 4b18472 to 3dfcd05 Compare June 2, 2026 17:18
@gnodet gnodet force-pushed the cascading-profile-activation branch 3 times, most recently from bd32d8c to cd869f3 Compare June 8, 2026 17:44
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.
@gnodet gnodet force-pushed the cascading-profile-activation branch from cd869f3 to b4ba025 Compare June 8, 2026 19:50
@cstamas

cstamas commented Jun 8, 2026

Copy link
Copy Markdown
Member

Is this whole PR only about cascading profile activation? There are mvnup changes for example...

gnodet added a commit to gnodet/maven that referenced this pull request Jul 10, 2026
Reviewed 3 PRs: apache#982 (PowerShell 3.9.x, syntax bugs), apache#878 (PowerShell master, needs Maven 4 rewrite), apache#33 (qualityManagement, oldest PR at 11 years). 45 reviews posted total. Only 3 truly unreviewed PRs remain: apache#2277, apache#1774, apache#71 (all large).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ConditionProfileActivatordoGetProperty(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 APIaddProfileProperties 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 MavenITgh12184CIFriendlyParentVersionTest confirms ${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 changedConditionProfileActivator.doGetProperty now 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

gnodet added a commit to gnodet/maven that referenced this pull request Jul 10, 2026
Reviewed final 3 PRs: apache#2277 (modernize codebase), apache#1774 (cascading profiles, found ReportSet merge bug), apache#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 <noreply@anthropic.com>
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