record.repoId ) );
return result;
}
}
Metadata metadata;
if ( RELEASE.equals( version ) )
{
metadata =
new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
Metadata.Nature.RELEASE );
}
else if ( LATEST.equals( version ) )
{
metadata =
new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
Metadata.Nature.RELEASE_OR_SNAPSHOT );
}
else if ( version.endsWith( SNAPSHOT ) )
{
WorkspaceReader workspace = session.getWorkspaceReader();
if ( workspace != null && workspace.findVersions( artifact ).contains( version ) )
{
metadata = null;
result.setRepository( workspace.getRepository() );
}
else
{
metadata =
new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), version, MAVEN_METADATA_XML,
Metadata.Nature.SNAPSHOT );
}
}
else
{
metadata = null;
}
if ( metadata == null )
{
result.setVersion( version );
}
else
{
List<MetadataRequest> metadataRequests = new ArrayList<MetadataRequest>( request.getRepositories().size() );
for ( RemoteRepository repository : request.getRepositories() )
{
MetadataRequest metadataRequest =
new MetadataRequest( metadata, repository, request.getRequestContext() );
metadataRequest.setDeleteLocalCopyIfMissing( true );
metadataRequest.setFavorLocalRepository( true );
metadataRequests.add( metadataRequest );
}
List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataRequests );
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
File localMetadataFile =
new File( lrm.getRepository().getBasedir(), lrm.getPathForLocalMetadata( metadata ) );
if ( localMetadataFile.isFile() )
{
metadata = metadata.setFile( localMetadataFile );
}
Map<String, VersionInfo> infos = new HashMap<String, VersionInfo>();
merge( artifact, infos, readVersions( session, metadata, result ),
session.getLocalRepositoryManager().getRepository() );