{
DefaultRepositorySystemSession session =
new DefaultRepositorySystemSession( legacySupport.getRepositorySession() );
session.setLocalRepositoryManager( LegacyLocalRepositoryManager.wrap( localRepository, repoSystem ) );
InstallRequest request = new InstallRequest();
org.sonatype.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact );
mainArtifact = mainArtifact.setFile( source );
request.addArtifact( mainArtifact );
for ( ArtifactMetadata metadata : artifact.getMetadataList() )
{
if ( metadata instanceof ProjectArtifactMetadata )
{
org.sonatype.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" );
pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() );
request.addArtifact( pomArtifact );
}
else if ( metadata instanceof SnapshotArtifactRepositoryMetadata
|| metadata instanceof ArtifactRepositoryMetadata )
{
// eaten, handled by repo system
}
else
{
request.addMetadata( new MetadataBridge( metadata ) );
}
}
try
{