Skip to content

Commit

Permalink
[MRESOLVER-309] Do not kill the build when unkown remote layout (#233)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cstamas committed Jan 4, 2023
1 parent c5619a6 commit afca3d8
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ public RemoteRepositoryFilter getRemoteRepositoryFilter( RepositorySystemSession
}

/**
* Caches layout instances for remote repository.
* Caches layout instances for remote repository. In case of unknown layout it returns {@code null}.
*
* @return the layout instance of {@code null} if layout not supported.
*/
private RepositoryLayout cacheLayout( RepositorySystemSession session, RemoteRepository remoteRepository )
{
Expand All @@ -124,7 +126,7 @@ private RepositoryLayout cacheLayout( RepositorySystemSession session, RemoteRep
}
catch ( NoRepositoryLayoutException e )
{
throw new RuntimeException( e );
return null;
}
} );
}
Expand Down Expand Up @@ -196,15 +198,25 @@ private PrefixesFilter( RepositorySystemSession session, Path basedir )
@Override
public Result acceptArtifact( RemoteRepository remoteRepository, Artifact artifact )
{
RepositoryLayout repositoryLayout = cacheLayout( session, remoteRepository );
if ( repositoryLayout == null )
{
return new SimpleResult( true, "Unsupported layout: " + remoteRepository );
}
return acceptPrefix( remoteRepository,
cacheLayout( session, remoteRepository ).getLocation( artifact, false ).getPath() );
repositoryLayout.getLocation( artifact, false ).getPath() );
}

@Override
public Result acceptMetadata( RemoteRepository remoteRepository, Metadata metadata )
{
RepositoryLayout repositoryLayout = cacheLayout( session, remoteRepository );
if ( repositoryLayout == null )
{
return new SimpleResult( true, "Unsupported layout: " + remoteRepository );
}
return acceptPrefix( remoteRepository,
cacheLayout( session, remoteRepository ).getLocation( metadata, false ).getPath() );
repositoryLayout.getLocation( metadata, false ).getPath() );
}

private Result acceptPrefix( RemoteRepository remoteRepository, String path )
Expand Down

0 comments on commit afca3d8

Please sign in to comment.