-
Notifications
You must be signed in to change notification settings - Fork 3k
[MNG-5913] Allow defining aliases for existing server configurations in settings.xml #2333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e4dd54d
cf2a2e7
5abd64e
214df5b
cbc98f1
6797f67
61e174a
9a84bff
c67cd09
c3009f8
44b6b2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,12 +26,15 @@ | |
| import java.io.IOException; | ||
| import java.io.StringReader; | ||
| import java.io.StringWriter; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import org.apache.maven.building.FileSource; | ||
| import org.apache.maven.building.Source; | ||
| import org.apache.maven.settings.Server; | ||
| import org.apache.maven.settings.Settings; | ||
| import org.apache.maven.settings.TrackableBase; | ||
| import org.apache.maven.settings.io.SettingsParseException; | ||
|
|
@@ -182,6 +185,7 @@ private Settings readSettings( | |
| } | ||
|
|
||
| settingsValidator.validate(settings, problems); | ||
| settings.setServers(new ArrayList<>(serversByIds(settings.getServers()))); | ||
|
|
||
| return settings; | ||
| } | ||
|
|
@@ -251,4 +255,18 @@ public Object execute(String expression, Object value) { | |
|
|
||
| return result; | ||
| } | ||
|
|
||
| private List<Server> serversByIds(List<Server> servers) { | ||
| return servers.stream() | ||
| .flatMap(server -> Stream.concat( | ||
|
slawekjaranowski marked this conversation as resolved.
|
||
| Stream.of(server), server.getAliases().stream().map(id -> serverAlias(server, id)))) | ||
| .toList(); | ||
| } | ||
|
|
||
| private Server serverAlias(Server server, String id) { | ||
|
slawekjaranowski marked this conversation as resolved.
|
||
| return new Server(org.apache.maven.api.settings.Server.newBuilder(server.getDelegate(), true) | ||
| .id(id) | ||
| .aliases(List.of()) | ||
| .build()); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks very ugly. It is the clien't responsibility to traverse the Settings object, no?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is the core of change. Based on additional tag - aliases we create a next server instance in memory on server list.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do remember that Modello allows to add Java code to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so you propose to override a getServers method directly in modelo?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, correct.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michael-o
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Share the spot where this is done. Modello made it possible :-(
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There is two templates for generating output from modello files: I see some of code in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a way to provide such code in settings.mdo
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michael-o any other remarks as implementation in modelo is not easy |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| <settings> | ||
| <localRepository>${user.home}/.m2/repository</localRepository> | ||
| <servers> | ||
| <server> | ||
| <id>server-1</id> | ||
| <username>username1</username> | ||
| <password>password1</password> | ||
| </server> | ||
| <server> | ||
| <id>server-2</id> | ||
| <username>username2</username> | ||
| <password>password2</password> | ||
| </server> | ||
| </servers> | ||
|
|
||
| </settings> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| <settings> | ||
| <localRepository>${user.home}/.m2/repository</localRepository> | ||
| <servers> | ||
| <server> | ||
| <id>server-1</id> | ||
| <aliases> | ||
| <alias>server-11</alias> | ||
| <alias>server-12</alias> | ||
| </aliases> | ||
| <username>username1</username> | ||
| <password>password1</password> | ||
| </server> | ||
| <server> | ||
| <id>server-2</id> | ||
| <aliases> | ||
| <alias>server-21</alias> | ||
| </aliases> | ||
| <username>username2</username> | ||
| <password>password2</password> | ||
| </server> | ||
| <server> | ||
| <id>server-3</id> | ||
| <username>username3</username> | ||
| <password>password3</password> | ||
| </server> | ||
| </servers> | ||
|
|
||
| </settings> |
Uh oh!
There was an error while loading. Please reload this page.