Repository navigation
Restore settings profile source in compatibility layer - #13854
codewithsinchana wants to merge 1 commit into
Conversation
gnodet-bot
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
|
Thank you for the detailed review. I understand that |
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_SETTINGSso that settings profiles are correctly identified. This change is limited to the compatibility conversion and does not modify the production model conversion logic.