Remove Profile getSource / setSource#12377
Conversation
e26615d to
852c95f
Compare
Remove getSource()/setSource() and SOURCE_POM/SOURCE_SETTINGS constants from the Profile class starting at model version 4.2.0. The 4.0.0 and 4.1.0 model versions retain these methods for backward compatibility. Replace usages in the impl layer (DefaultProfileSelector, SettingsUtilsV4) with InputLocation/InputSource checks. POM-originating profiles are now identified by having a non-null InputSource.getModelId(). The compat layer is unchanged. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
852c95f to
5e98283
Compare
…files Settings profiles converted via SettingsUtilsV4 get an InputSource with modelId="" (empty string, not null), so the check must also exclude empty strings to correctly identify non-POM profiles. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ultProfileSelector Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Removes legacy Profile source tracking (getSource/setSource and related constants) from the API model starting with model version 4.2.0, and updates the impl layer to distinguish POM vs settings profiles via InputLocation/InputSource (per #2569).
Changes:
- Split API model code generation segments so
Profile.getSource/setSourceexist only for 4.0.x and 4.1.x, and are removed for 4.2.0+. - Update
DefaultProfileSelectorto classify “from POM” profiles based on a non-emptyInputSource.getModelId(). - Remove impl-layer writes to
Profile.setSource("settings.xml")and add tests covering the updated activation behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultProfileSelectorTest.java | Adds coverage for POM vs settings profile handling using InputSource model id, including edge cases. |
| impl/maven-impl/src/main/java/org/apache/maven/impl/SettingsUtilsV4.java | Stops setting Profile source explicitly; relies on InputLocation/InputSource instead. |
| impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultProfileSelector.java | Replaces Profile.getSource() checks with InputSource.getModelId()-based origin detection. |
| api/maven-api-model/src/main/mdo/maven.mdo | Adjusts generated API model versions: retains source API for 4.0.x/4.1.x and removes it for 4.2.0+. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gnodet
left a comment
There was a problem hiding this comment.
LGTM — Clean removal of the legacy Profile.getSource()/setSource() methods from the 4.2.0+ API model, correctly replacing usages in the impl layer with InputSource.getModelId() checks. The compat layer retains backward compatibility for 4.0.x/4.1.x consumers.
Highlights:
- The version segmentation strategy (4.0.0/4.0.99, 4.1.0/4.1.99, 4.2.0+) is well-structured and ensures backward compatibility at each layer
- The replacement mechanism using
InputSource.getModelId()is sound: POM profiles get a modelId during parsing while settings profiles get an empty string, naturally distinguishing profile sources without a separate mutable field - The new
DefaultProfileSelectorTestis thorough: covers POM-only, settings-only, mixed, null-modelId, no-location, and exception cases - japicmp passes, confirming no binary compatibility violations
- CI is fully green across all platforms
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
Summary
Profile.getSource(),Profile.setSource(),Profile.SOURCE_POM, andProfile.SOURCE_SETTINGSstarting at model version 4.2.0 (per Remove profile getSource / setSource #2569)InputLocation/InputSourcechecks: POM profiles are identified by having a non-nullInputSource.getModelId()getSource()/setSource()via its own model code segmentFiles changed (3):
api/maven-api-model/src/main/mdo/maven.mdo— split4.1.0+segment into4.1.0/4.1.99(keeps source methods) and4.2.0+(removes them); fix4.0.0/4.0.99to use own field instead of delegatingimpl/maven-impl/.../DefaultProfileSelector.java— replaceProfile.SOURCE_POM.equals(profile.getSource())withisFromPom()usingInputSource.getModelId()impl/maven-impl/.../SettingsUtilsV4.java— removevalue.setSource("settings.xml")Closes #2569
Test plan
getSource/setSourcegetSource/setSourcevia own field🤖 Generated with Claude Code