Skip to content

Remove Profile getSource / setSource#12377

Open
gnodet wants to merge 3 commits into
apache:masterfrom
gnodet:fix-2569-remove-profile-getSource
Open

Remove Profile getSource / setSource#12377
gnodet wants to merge 3 commits into
apache:masterfrom
gnodet:fix-2569-remove-profile-getSource

Conversation

@gnodet

@gnodet gnodet commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Removes Profile.getSource(), Profile.setSource(), Profile.SOURCE_POM, and Profile.SOURCE_SETTINGS starting at model version 4.2.0 (per Remove profile getSource / setSource #2569)
  • The 4.0.0 and 4.1.0 model versions retain these methods for backward compatibility (the 4.0.0 segment now uses its own field instead of delegating to the API model)
  • Replaces usages in the impl layer with InputLocation / InputSource checks: POM profiles are identified by having a non-null InputSource.getModelId()
  • The compat layer is unchanged — it still has getSource()/setSource() via its own model code segment

Files changed (3):

  • api/maven-api-model/src/main/mdo/maven.mdo — split 4.1.0+ segment into 4.1.0/4.1.99 (keeps source methods) and 4.2.0+ (removes them); fix 4.0.0/4.0.99 to use own field instead of delegating
  • impl/maven-impl/.../DefaultProfileSelector.java — replace Profile.SOURCE_POM.equals(profile.getSource()) with isFromPom() using InputSource.getModelId()
  • impl/maven-impl/.../SettingsUtilsV4.java — remove value.setSource("settings.xml")

Closes #2569

Test plan

  • Full build passes (all 38 modules, all tests green)
  • API Profile (4.2.0+) no longer has getSource/setSource
  • Compat Profile retains getSource/setSource via own field
  • No japicmp compatibility violations
  • CI build passes

🤖 Generated with Claude Code

@gnodet gnodet force-pushed the fix-2569-remove-profile-getSource branch from e26615d to 852c95f Compare June 26, 2026 07:38
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>
@gnodet gnodet force-pushed the fix-2569-remove-profile-getSource branch from 852c95f to 5e98283 Compare June 26, 2026 08:13
gnodet and others added 2 commits June 26, 2026 09:26
…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>
@gnodet gnodet marked this pull request as ready for review June 26, 2026 14:20
@gnodet gnodet added this to the 4.1.0 milestone Jun 26, 2026
@gnodet gnodet requested a review from Copilot July 7, 2026 08:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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/setSource exist only for 4.0.x and 4.1.x, and are removed for 4.2.0+.
  • Update DefaultProfileSelector to classify “from POM” profiles based on a non-empty InputSource.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.

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.

Remove profile getSource / setSource

2 participants