Skip to content

Commit afca3d8

Browse files
authored
[MRESOLVER-309] Do not kill the build when unkown remote layout (#233)
In case remote repository defines unsupported layout, filter should just let it pass (as resolver will gracefully fail with it anyway), while throwing RuntimeException caused abruptly stopped build. --- https://issues.apache.org/jira/browse/MRESOLVER-309
1 parent c5619a6 commit afca3d8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/filter/PrefixesRemoteRepositoryFilterSource.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ public RemoteRepositoryFilter getRemoteRepositoryFilter( RepositorySystemSession
112112
}
113113

114114
/**
115-
* Caches layout instances for remote repository.
115+
* Caches layout instances for remote repository. In case of unknown layout it returns {@code null}.
116+
*
117+
* @return the layout instance of {@code null} if layout not supported.
116118
*/
117119
private RepositoryLayout cacheLayout( RepositorySystemSession session, RemoteRepository remoteRepository )
118120
{
@@ -124,7 +126,7 @@ private RepositoryLayout cacheLayout( RepositorySystemSession session, RemoteRep
124126
}
125127
catch ( NoRepositoryLayoutException e )
126128
{
127-
throw new RuntimeException( e );
129+
return null;
128130
}
129131
} );
130132
}
@@ -196,15 +198,25 @@ private PrefixesFilter( RepositorySystemSession session, Path basedir )
196198
@Override
197199
public Result acceptArtifact( RemoteRepository remoteRepository, Artifact artifact )
198200
{
201+
RepositoryLayout repositoryLayout = cacheLayout( session, remoteRepository );
202+
if ( repositoryLayout == null )
203+
{
204+
return new SimpleResult( true, "Unsupported layout: " + remoteRepository );
205+
}
199206
return acceptPrefix( remoteRepository,
200-
cacheLayout( session, remoteRepository ).getLocation( artifact, false ).getPath() );
207+
repositoryLayout.getLocation( artifact, false ).getPath() );
201208
}
202209

203210
@Override
204211
public Result acceptMetadata( RemoteRepository remoteRepository, Metadata metadata )
205212
{
213+
RepositoryLayout repositoryLayout = cacheLayout( session, remoteRepository );
214+
if ( repositoryLayout == null )
215+
{
216+
return new SimpleResult( true, "Unsupported layout: " + remoteRepository );
217+
}
206218
return acceptPrefix( remoteRepository,
207-
cacheLayout( session, remoteRepository ).getLocation( metadata, false ).getPath() );
219+
repositoryLayout.getLocation( metadata, false ).getPath() );
208220
}
209221

210222
private Result acceptPrefix( RemoteRepository remoteRepository, String path )

0 commit comments

Comments
 (0)