Skip to content

Report parent POM profiles as inactive - #441

Merged
slawekjaranowski merged 4 commits into
apache:masterfrom
efegokdemir:codex/issue-387-parent-active
Nov 14, 2026
Merged

slawekjaranowski merged 4 commits into
apache:masterfrom
efegokdemir:codex/issue-387-parent-active

Conversation

@efegokdemir

@efegokdemir efegokdemir commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #387. Use Maven's injected profile IDs when reporting profiles in help:all-profiles, so parent-POM profiles activated for the current project are shown as active. This follows the same profile information used by help:active-profiles; settings profiles are not incorrectly presented as POM profiles.

Testing

The integration tests cover injected parent profiles, inactive parent and child profiles, and a settings profile. The maintainer reports CI passing on Maven 3.10 and 4.0.0-rc-7. The previous local test count is omitted because it predates the current implementation.

@slachiewicz slachiewicz added the bug Something isn't working label Oct 27, 2026
@slachiewicz
slachiewicz force-pushed the codex/issue-387-parent-active branch from a814610 to d4c274d Compare October 27, 2026 20:56
@github-actions

This comment has been minimized.

@slachiewicz slachiewicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A profile activated in the parent POM is active for the child module: Maven injects it during the child's model build and records it in MavenProject.getInjectedProfileIds(), which is also what help:active-profiles reports. The original all-profiles-parent-pom expectation (active in both runs) is correct, so this change, and the new unit test, make all-profiles disagree with active-profiles. Could you instead mark a parent's profile as active when getInjectedProfileIds() lists it under the parent's model id, and keep the existing IT?

Keep all-profiles consistent with active-profiles for parent and grandparent profiles, including CI-friendly versions. Restore the original parent-profile integration test.

Generated-by: OpenAI

@slawekjaranowski slawekjaranowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the update — using MavenProject.getInjectedProfileIds() looks like the right approach, and CI is green on both Maven 3.10 and 4.0.0-rc-7.

Title / description are out of date — they still describe the earlier approach ("report parent POM profiles as inactive"). Could you update them? Suggested title:

Mark parent POM profiles as active only when injected into the current project

and description along the lines of:

help:all-profiles reported profiles declared in parent POMs as active based on the parent project's own build context. Now a parent profile is reported as active only if it was actually injected into the current project's model (MavenProject.getInjectedProfileIds()).

Fixes #387

Simplification — I left inline suggestions that replace the model-ID reconstruction with a plain set of all injected profile IDs (rationale in the comment on the loop). They can be applied together via "Add suggestion to batch"; with all of them applied, mvn verify -Prun-its passes locally on Maven 3.10 and 4.0.0-rc-7.

(Optional) An IT reproducing the exact #387 scenario (a parent profile activated in the parent's context but not in the child's) would verify the behaviour against real model building, not only mocks.

Collect injected POM profile IDs without reconstructing model coordinates.
Exclude the documented external-profile entry so inactive ancestor profiles
do not overwrite an active settings profile's source. Retain POM activity
when the same ID is genuinely injected from both sources.

Add settings-only and dual-active collision unit tests and a real parent-POM
integration regression. Validated with Maven 3.10.0 (35 unit, 37 integration)
and Maven 4.0.0-rc-7 (35 unit, 34 integration, 3 version skips) on JDK 17.

Generated-by: OpenAI
@slawekjaranowski
slawekjaranowski merged commit 14a2570 into apache:master Nov 14, 2026
15 checks passed
@github-actions github-actions Bot added this to the 3.5.3 milestone Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AllProfilesMojo.addProjectPomProfiles() uses parent build context for active profiles

3 participants