Skip to content

Restore settings profile source in compatibility layer - #13854

Closed
codewithsinchana wants to merge 1 commit into
apache:masterfrom
codewithsinchana:fix/settings-profile-source-2569
Closed

codewithsinchana wants to merge 1 commit into
apache:masterfrom
codewithsinchana:fix/settings-profile-source-2569

Conversation

@codewithsinchana

@codewithsinchana codewithsinchana commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

This change restores the settings profile source when converting a profile from the Maven settings model to the Maven 3 compatibility model. Previously, the converted profile did not retain its settings source, which could cause it to be treated as a POM profile. The conversion now explicitly sets the source to Profile.SOURCE_SETTINGS so that settings profiles are correctly identified. This change is limited to the compatibility conversion and does not modify the production model conversion logic.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix is not needed — SettingsUtilsV4.convertFromSettingsProfile() already sets source to "settings.xml" on the API-model Profile delegate (see SettingsUtilsV4.java, line 271: value.setSource("settings.xml")). The compat-layer org.apache.maven.model.Profile delegates both getSource() and setSource() to the same underlying object, so calling setSource again here is a no-op.

You can verify this by writing a unit test on the current master branch — convertFromSettingsProfile(settingsProfile).getSource() already returns "settings.xml" without this change.

Additionally, open PR #12377 is working to remove Profile.getSource() / setSource() entirely. If that PR merges after this one, this new call would become a compile error.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

org.apache.maven.model.Profile result = new org.apache.maven.model.Profile(
SettingsUtilsV4.convertFromSettingsProfile(settingsProfile.getDelegate()));
result.setSource(org.apache.maven.model.Profile.SOURCE_SETTINGS);
return result;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SettingsUtilsV4.convertFromSettingsProfile() already calls value.setSource("settings.xml") on the API model profile before returning it (line 271 of SettingsUtilsV4.java). Since the compat Profile delegates setSource/getSource to that same object, this call sets the same value that is already there. No test on current master would fail without this line.

Also, open PR #12377 plans to remove getSource/setSource from the compat Profile entirely — this new call would then cause a compile error on that branch.

@codewithsinchana

Copy link
Copy Markdown
Contributor Author

Thank you for the detailed review. I understand that SettingsUtilsV4.convertFromSettingsProfile() already sets the profile source and that the compatibility model delegates to the same underlying object. I also understand the potential compatibility issue with PR #12377. I'll verify the behavior against the current master branch and reconsider this change to avoid introducing redundant code.

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.

3 participants