Skip to content
Closed
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 @@ -69,6 +69,8 @@ public class DefaultVersionRangeResolver

private static final String MAVEN_METADATA_XML = "maven-metadata.xml";

private static final String SNAPSHOT = "SNAPSHOT";

private final MetadataResolver metadataResolver;
private final SyncContextFactory syncContextFactory;
private final RepositoryEventDispatcher repositoryEventDispatcher;
Expand Down Expand Up @@ -183,9 +185,11 @@ private Map<String, ArtifactRepository> getVersions( RepositorySystemSession ses
}

Versioning versioning = readVersions( session, trace, metadataResult.getMetadata(), repository, result );
RemoteRepository remoteRepository = metadataResult.getRequest().getRepository();

for ( String version : versioning.getVersions() )
{
if ( !versionIndex.containsKey( version ) )
if ( isEnabled( remoteRepository, version ) && !versionIndex.containsKey( version ) )
{
versionIndex.put( version, repository );
}
Expand All @@ -195,6 +199,18 @@ private Map<String, ArtifactRepository> getVersions( RepositorySystemSession ses
return versionIndex;
}

private boolean isEnabled( RemoteRepository remoteRepository, String version )
{
if ( remoteRepository == null )
{
return true;
}

boolean snapshot = version != null && version.endsWith( SNAPSHOT );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about timestamped snapshots?

Copy link
Copy Markdown
Contributor Author

@hgschmie hgschmie Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cstamas ,

Thank you for looking at this. I do not understand this comment. The check is similar to the code in the DefaultVersionResolver (where it determines whether a local file is a SNAPSHOT version by checking that it ends with 'SNAPSHOT' (https://github.com/apache/maven/blob/master/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java#L208).

Can you explain a bit more what you mean by "timestamped snapshots" ?


return remoteRepository.getPolicy( snapshot ).isEnabled();
}

private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
ArtifactRepository repository, VersionRangeResult result )
{
Expand Down Expand Up @@ -238,4 +254,4 @@ private void invalidMetadata( RepositorySystemSession session, RequestTrace trac
repositoryEventDispatcher.dispatch( event.build() );
}

}
}