Skip to content

[MNG-5913] Allow defining aliases for existing server configurations in settings.xml#2333

Merged
slawekjaranowski merged 11 commits into
apache:masterfrom
slawekjaranowski:MNG-5913
Jul 12, 2026
Merged

[MNG-5913] Allow defining aliases for existing server configurations in settings.xml#2333
slawekjaranowski merged 11 commits into
apache:masterfrom
slawekjaranowski:MNG-5913

Conversation

@slawekjaranowski

Copy link
Copy Markdown
Member

Add the next tag ids to the server in settings.xml

Additional server will be created in memory by SettingsBuilder, so the generated configuration should be transparent to other as Settings#getServers() will return complete list.


https://issues.apache.org/jira/browse/MNG-5913

@slawekjaranowski slawekjaranowski added the enhancement New feature or request label May 13, 2025
@slawekjaranowski slawekjaranowski self-assigned this May 13, 2025
Comment thread api/maven-api-settings/src/main/mdo/settings.mdo Outdated
Comment thread api/maven-api-settings/src/main/mdo/settings.mdo
@cstamas

cstamas commented May 13, 2025

Copy link
Copy Markdown
Member

This needs to be made sure will not break Maven 3, as same settings is shared by both currently.

@slawekjaranowski

Copy link
Copy Markdown
Member Author

This needs to be made sure will not break Maven 3, as same settings is shared by both currently.

unit test, looks ok for me.

I tested with: mvn help:effective-settings

@slawekjaranowski

Copy link
Copy Markdown
Member Author

ok, who is willing to work on it with me?
If proposition will be generally accepted I will do similar in 3.9.x

I hope such feature will be valuable.

@cstamas

cstamas commented May 14, 2025

Copy link
Copy Markdown
Member

Well, settings with current 3.9.9 are NOT read:

[WARNING] 
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Unrecognised tag: 'aliases' (position: START_TAG seen ...</id>\n     <aliases>... @61:15)  @ /home/cstamas/.m2/settings.xml, line 61, column 15
[WARNING] 

Or this is "ok"? Is settings loaded partially or discaded?

@cstamas

cstamas commented May 14, 2025

Copy link
Copy Markdown
Member

I am willing to jump in as Njord does something similar, but my concern is that Maven 3.x is not "forgiving" while readint settings.xml AFAIK. And if we modify XML then things like ./mvnw will work ONLY (for user) if 3.9.10 used?

@slawekjaranowski

Copy link
Copy Markdown
Member Author

Well, settings with current 3.9.9 are NOT read:

[WARNING] 
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Unrecognised tag: 'aliases' (position: START_TAG seen ...</id>\n     <aliases>... @61:15)  @ /home/cstamas/.m2/settings.xml, line 61, column 15
[WARNING] 

Or this is "ok"? Is settings loaded partially or discaded?

it is correct because 3.9.x does not have it yet

@slawekjaranowski

Copy link
Copy Markdown
Member Author

I am willing to jump in as Njord does something similar, but my concern is that Maven 3.x is not "forgiving" while readint settings.xml AFAIK. And if we modify XML then things like ./mvnw will work ONLY (for user) if 3.9.10 used?

I hope we can have next version of settings schema for 3.9.x ... so if someone update own settings alos will use newer version of Maven

@Pankraz76 Pankraz76 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.

already very nice.
please give last dedication, to reach infinitive higher-order function.

Comment thread impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSettingsBuilder.java Outdated

@Pankraz76 Pankraz76 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.

polish

Comment thread impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSettingsBuilder.java Outdated
Comment thread impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSettingsBuilder.java Outdated
@slawekjaranowski

Copy link
Copy Markdown
Member Author

@gnodet @Pankraz76 last suggestions applied

@gnodet gnodet 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.

Review: [MNG-5913] Allow defining aliases for existing server configurations

This is a well-implemented feature that addresses a real pain point — users who need the same credentials for multiple repository servers currently have to duplicate the entire <server> block.

What looks good

  • Dual-layer implementation: Changes in both the v4 API (impl/maven-impl) and the v3 compat layer (compat/maven-settings-builder) with separate test suites for each.
  • Alias expansion logic: Correct — each settings file's aliases are expanded within that file before merging. Cross-source ID collisions are handled by the existing merge logic (last-wins).
  • Validation coverage: Tests cover basic servers (no aliases), servers with aliases (verifying expansion), duplicate alias detection, alias-equals-server-ID detection, and empty alias validation.
  • Schema versioning: The forcedIOModelVersion bump to 1.3.0 and <version>1.3.0+</version> on the aliases field follow standard Modello practice for schema evolution.
  • Deep copy: Server.newBuilder(server, true) correctly deep-copies all fields (including configuration DOM elements) to aliased servers.
  • Project settings: Aliases are correctly warned about and stripped from project settings, consistent with how other unsupported features are handled.

Open coordination items

The backward compatibility discussion between @cstamas, @michael-o, and @slawekjaranowski about whether settings.xml files using <aliases> should work across Maven versions is the main open question. This is a policy/coordination decision, not a code issue — the implementation is technically sound.


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

gnodet added a commit to gnodet/maven that referenced this pull request Jul 10, 2026
Reviewed 3 PRs: apache#2333 (server aliases, clean), apache#10971 (test, LGTM),
apache#11186 (namespace validation, needs rework). 18 reviews total.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@slawekjaranowski

Copy link
Copy Markdown
Member Author

The backward compatibility discussion between @cstamas, @michael-o, and @slawekjaranowski about whether settings.xml files using <aliases> should work across Maven versions is the main open question. This is a policy/coordination decision, not a code issue — the implementation is technically sound.

settings.xml is locally managed by users in own controlled environments.
If someone use new feature should be aware that only works with newer Maven version.

Should be not a compatibility problem.

So as technically change is ok, should not be block to merge.

@slawekjaranowski
slawekjaranowski requested a review from gnodet July 11, 2026 20:26

@gnodet gnodet 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.

Re-review: Allow defining aliases for existing server configurations

Verdict: APPROVE

No new commits since the previous review (2026-07-10). The updatedAt change was triggered by the author's comment (2026-07-11) responding to the backward compatibility discussion.

Author's response to backward compat concern

slawekjaranowski argues that settings.xml is locally managed by users, so adopting the <aliases> feature inherently requires a newer Maven version — this should not block the merge. This is a reasonable position for an opt-in feature in a user-managed file.

Code assessment (unchanged)

The implementation remains clean across all reviewed dimensions:

  • Alias expansion correct in both v4 (DefaultSettingsBuilder) and v3 compat layers
  • Validation covers: duplicate alias-vs-id, duplicate alias-vs-alias, alias-equals-own-id, empty alias values
  • Comprehensive test coverage with dedicated XML fixtures
  • Schema versioning (1.3.0+, forcedIOModelVersion=1.3.0) follows Modello conventions
  • !isProjectSettings guard and project-settings alias stripping are correct

The remaining backward compat discussion is a project governance decision among committers, not a code issue.


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

gnodet added a commit to gnodet/maven that referenced this pull request Jul 11, 2026

@gnodet gnodet 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.

Re-review: Server aliases — post-rebase

Verdict: APPROVE

Pure rebase onto latest base branch — same 20 files, same 641+/15−, same 11 commits with identical messages. No code changes. Previous approval stands.


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

gnodet added a commit to gnodet/maven that referenced this pull request Jul 11, 2026
@slawekjaranowski
slawekjaranowski merged commit 09b2dfc into apache:master Jul 12, 2026
41 of 42 checks passed
@slawekjaranowski
slawekjaranowski deleted the MNG-5913 branch July 12, 2026 13:17
@github-actions github-actions Bot added this to the 4.1.0 milestone Jul 12, 2026
slawekjaranowski added a commit that referenced this pull request Jul 13, 2026
…in settings.xml

* [MNG-5913] Allow defining aliases for existing server configurations in settings.xml

Add the next tag aliases to the server in settings.xml

Additional server will be created in memory by SettingsBuilder,
so the generated configuration should be transparent to other
as Settings#getServers() will return complete list.

Based on commit 09b2dfc #2333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request mvn4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MNG-5913] Allow to define aliases for existing server configurations in settings.xml

6 participants