Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public RepositoryLayout newInstance( RepositorySystemSession session, RemoteRepo
}

return new Maven2RepositoryLayout(
new ArrayList<>( checksumAlgorithmFactorySelector.getChecksumAlgorithmFactories() ),
checksumsAlgorithms,
omitChecksumsForExtensions
);
Expand All @@ -150,15 +151,18 @@ public RepositoryLayout newInstance( RepositorySystemSession session, RemoteRepo
private static class Maven2RepositoryLayout
implements RepositoryLayout
{
private final List<ChecksumAlgorithmFactory> allChecksumAlgorithms;

private final List<ChecksumAlgorithmFactory> checksumAlgorithms;
private final List<ChecksumAlgorithmFactory> configuredChecksumAlgorithms;

private final Set<String> extensionsWithoutChecksums;

private Maven2RepositoryLayout( List<ChecksumAlgorithmFactory> checksumAlgorithms,
private Maven2RepositoryLayout( List<ChecksumAlgorithmFactory> allChecksumAlgorithms,
List<ChecksumAlgorithmFactory> configuredChecksumAlgorithms,
Set<String> extensionsWithoutChecksums )
{
this.checksumAlgorithms = Collections.unmodifiableList( checksumAlgorithms );
this.allChecksumAlgorithms = Collections.unmodifiableList( allChecksumAlgorithms );
this.configuredChecksumAlgorithms = Collections.unmodifiableList( configuredChecksumAlgorithms );
this.extensionsWithoutChecksums = requireNonNull( extensionsWithoutChecksums );
}

Expand All @@ -177,7 +181,7 @@ private URI toUri( String path )
@Override
public List<ChecksumAlgorithmFactory> getChecksumAlgorithmFactories()
{
return checksumAlgorithms;
return configuredChecksumAlgorithms;
}

@Override
Expand Down Expand Up @@ -263,8 +267,8 @@ public List<ChecksumLocation> getChecksumLocations( Metadata metadata, boolean u

private List<ChecksumLocation> getChecksumLocations( URI location )
{
List<ChecksumLocation> checksumLocations = new ArrayList<>( checksumAlgorithms.size() );
for ( ChecksumAlgorithmFactory checksumAlgorithmFactory : checksumAlgorithms )
List<ChecksumLocation> checksumLocations = new ArrayList<>( configuredChecksumAlgorithms.size() );
for ( ChecksumAlgorithmFactory checksumAlgorithmFactory : configuredChecksumAlgorithms )
{
checksumLocations.add( ChecksumLocation.forLocation( location, checksumAlgorithmFactory ) );
}
Expand All @@ -273,7 +277,7 @@ private List<ChecksumLocation> getChecksumLocations( URI location )

private boolean isChecksum( String extension )
{
return checksumAlgorithms.stream().anyMatch( a -> extension.endsWith( "." + a.getFileExtension() ) );
return allChecksumAlgorithms.stream().anyMatch( a -> extension.endsWith( "." + a.getFileExtension() ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,17 @@ public void testCustomChecksumsIgnored()
assertEquals( 0, checksums.size() );
}

@Test
public void testNotConfiguredButSupportedChecksumsHandledAsChecksums()
throws Exception
{
layout = factory.newInstance( session, newRepo( "default" ) );
DefaultArtifact artifact = new DefaultArtifact( "g.i.d", "a-i.d", "cls", "jar.sha512", "1.0" );
URI uri = layout.getLocation( artifact, true );
List<ChecksumLocation> checksums = layout.getChecksumLocations( artifact, true, uri );
assertEquals( 0, checksums.size() );
}

@Test
public void testCustomChecksumsIgnored_IllegalInout()
throws Exception
Expand Down