@@ -87,15 +87,15 @@ public abstract class AspectModelMojo extends AbstractMojo {
87
87
protected boolean detailedValidationMessages ;
88
88
89
89
@ Parameter
90
- protected String githubServerId ;
90
+ protected List < String > githubServerIds ;
91
91
92
92
@ Parameter ( defaultValue = "${session}" , readonly = true )
93
93
protected MavenSession mavenSession ;
94
94
95
95
@ Parameter
96
96
protected Map <String , String > resolutionConfiguration = new HashMap <>();
97
97
98
- protected GithubModelSourceConfig gitHubConfig ;
98
+ protected List < GithubModelSourceConfig > gitHubConfigs = new ArrayList <>() ;
99
99
100
100
private Map <AspectModel , Aspect > aspects ;
101
101
@@ -141,8 +141,10 @@ private AspectModelLoader createAspectModelLoader() throws MojoExecutionExceptio
141
141
final Path modelsRoot = Path .of ( modelsRootDirectory );
142
142
strategies .add ( new FileSystemStrategy ( modelsRoot ) );
143
143
}
144
- if ( gitHubConfig != null ) {
145
- strategies .add ( new GitHubStrategy ( gitHubConfig ) );
144
+ if ( !gitHubConfigs .isEmpty () ) {
145
+ for ( GithubModelSourceConfig gitHubConfig : gitHubConfigs ) {
146
+ strategies .add ( new GitHubStrategy ( gitHubConfig ) );
147
+ }
146
148
}
147
149
if ( strategies .isEmpty () ) {
148
150
throw new MojoExecutionException (
@@ -206,50 +208,54 @@ public void execute() throws MojoExecutionException, MojoFailureException {
206
208
return ;
207
209
}
208
210
209
- if ( githubServerId != null ) {
211
+ if ( githubServerIds != null && ! githubServerIds . isEmpty () ) {
210
212
if ( mavenSession == null ) {
211
213
getLog ().warn ( "Could not read Maven session, ignoring GitHub server configuration." );
212
214
} else {
213
- final Server server = mavenSession .getSettings ().getServer ( githubServerId );
214
- if ( server != null ) {
215
- final Xpp3Dom dom = (Xpp3Dom ) server .getConfiguration ();
216
- final String [] repositoryParts = Optional .ofNullable ( dom .getChild ( "repository" ) )
217
- .map ( Xpp3Dom ::getValue )
218
- .map ( repository -> repository .split ( "/" ) )
219
- .orElseThrow ( () -> new MojoExecutionException ( "Expected <repository> in settings.xml is missing" ) );
220
- final String directory = Optional .ofNullable ( dom .getChild ( "directory" ) )
221
- .map ( Xpp3Dom ::getValue )
222
- .orElse ( "" );
223
- final String token = Optional .ofNullable ( dom .getChild ( "token" ) )
224
- .map ( Xpp3Dom ::getValue )
225
- .orElse ( null );
226
-
227
- final GithubRepository .Ref ref = Optional .ofNullable ( dom .getChild ( "branch" ) )
228
- .map ( Xpp3Dom ::getValue )
229
- .<GithubRepository .Ref > map ( GithubRepository .Branch ::new )
230
- .or ( () -> Optional .ofNullable ( dom .getChild ( "tag" ) )
231
- .map ( Xpp3Dom ::getValue )
232
- .map ( GithubRepository .Tag ::new ) )
233
- .orElse ( new GithubRepository .Branch ( "main" ) );
234
-
235
- final List <Proxy > proxies = mavenSession .getSettings ().getProxies ();
236
- final ProxyConfig proxyConfig = Optional .ofNullable ( proxies ).stream ().flatMap ( Collection ::stream )
237
- .filter ( proxy -> proxy .getProtocol ().equals ( "https" ) )
238
- .findFirst ()
239
- .or ( () -> Optional .ofNullable ( proxies ).stream ().flatMap ( Collection ::stream )
240
- .filter ( proxy -> proxy .getProtocol ().equals ( "http" ) )
241
- .findFirst () )
242
- .filter ( Proxy ::isActive )
243
- .map ( proxy -> ProxyConfig .from ( proxy .getHost (), proxy .getPort () ) )
244
- .orElse ( ProxyConfig .detectProxySettings () );
245
-
246
- final GithubRepository repository = new GithubRepository ( repositoryParts [0 ], repositoryParts [1 ], ref );
247
- gitHubConfig = GithubModelSourceConfigBuilder .builder ()
248
- .proxyConfig ( proxyConfig )
249
- .repository ( repository )
250
- .directory ( directory )
251
- .token ( token )
252
- .build ();
215
+ for ( String serverId : githubServerIds ) {
216
+ final Server server = mavenSession .getSettings ().getServer ( serverId );
217
+ if ( server != null ) {
218
+ final Xpp3Dom dom = (Xpp3Dom ) server .getConfiguration ();
219
+ final String [] repositoryParts = Optional .ofNullable ( dom .getChild ( "repository" ) )
220
+ .map ( Xpp3Dom ::getValue )
221
+ .map ( repository -> repository .split ( "/" ) )
222
+ .orElseThrow ( () -> new MojoExecutionException ( "Expected <repository> in settings.xml is missing" ) );
223
+ final String directory = Optional .ofNullable ( dom .getChild ( "directory" ) )
224
+ .map ( Xpp3Dom ::getValue )
225
+ .orElse ( "" );
226
+ final String token = Optional .ofNullable ( dom .getChild ( "token" ) )
227
+ .map ( Xpp3Dom ::getValue )
228
+ .orElse ( null );
229
+
230
+ final GithubRepository .Ref ref = Optional .ofNullable ( dom .getChild ( "branch" ) )
231
+ .map ( Xpp3Dom ::getValue )
232
+ .<GithubRepository .Ref > map ( GithubRepository .Branch ::new )
233
+ .or ( () -> Optional .ofNullable ( dom .getChild ( "tag" ) )
234
+ .map ( Xpp3Dom ::getValue )
235
+ .map ( GithubRepository .Tag ::new ) )
236
+ .orElse ( new GithubRepository .Branch ( "main" ) );
237
+
238
+ final List <Proxy > proxies = mavenSession .getSettings ().getProxies ();
239
+ final ProxyConfig proxyConfig = Optional .ofNullable ( proxies ).stream ().flatMap ( Collection ::stream )
240
+ .filter ( proxy -> proxy .getProtocol ().equals ( "https" ) )
241
+ .findFirst ()
242
+ .or ( () -> Optional .ofNullable ( proxies ).stream ().flatMap ( Collection ::stream )
243
+ .filter ( proxy -> proxy .getProtocol ().equals ( "http" ) )
244
+ .findFirst () )
245
+ .filter ( Proxy ::isActive )
246
+ .map ( proxy -> ProxyConfig .from ( proxy .getHost (), proxy .getPort () ) )
247
+ .orElse ( ProxyConfig .detectProxySettings () );
248
+
249
+ final GithubRepository repository = new GithubRepository ( repositoryParts [0 ], repositoryParts [1 ], ref );
250
+ GithubModelSourceConfig gitHubConfig = GithubModelSourceConfigBuilder .builder ()
251
+ .proxyConfig ( proxyConfig )
252
+ .repository ( repository )
253
+ .directory ( directory )
254
+ .token ( token )
255
+ .build ();
256
+
257
+ gitHubConfigs .add ( gitHubConfig );
258
+ }
253
259
}
254
260
}
255
261
}
0 commit comments