[MNG-4452] Metadata for snapshots should include classifier

o Added boolean system/execution property maven.metadata.legacy to enable 1.0.0 format to allow for interop with existing repo mans that could choke on the new format when processing it on the server side

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@995081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-09-08 15:04:45 +00:00
parent 01ae5291a8
commit 7e99c2999b
4 changed files with 24 additions and 11 deletions

View File

@ -55,7 +55,6 @@ final class LocalSnapshotMetadata
versioning.setSnapshot( snapshot );
Metadata metadata = new Metadata();
metadata.setModelVersion( "1.0.0" );
metadata.setVersioning( versioning );
metadata.setGroupId( artifact.getGroupId() );
metadata.setArtifactId( artifact.getArtifactId() );

View File

@ -48,20 +48,27 @@ final class RemoteSnapshotMetadata
private final Map<String, SnapshotVersion> versions = new LinkedHashMap<String, SnapshotVersion>();
public RemoteSnapshotMetadata( Artifact artifact )
private final boolean legacyFormat;
public RemoteSnapshotMetadata( Artifact artifact, boolean legacyFormat )
{
super( createMetadata( artifact ), null );
super( createMetadata( artifact, legacyFormat ), null );
this.legacyFormat = legacyFormat;
}
private RemoteSnapshotMetadata( Metadata metadata, File file )
private RemoteSnapshotMetadata( Metadata metadata, File file, boolean legacyFormat )
{
super( metadata, file );
this.legacyFormat = legacyFormat;
}
private static Metadata createMetadata( Artifact artifact )
private static Metadata createMetadata( Artifact artifact, boolean legacy )
{
Metadata metadata = new Metadata();
if ( !legacy )
{
metadata.setModelVersion( "1.1.0" );
}
metadata.setGroupId( artifact.getGroupId() );
metadata.setArtifactId( artifact.getArtifactId() );
metadata.setVersion( artifact.getBaseVersion() );
@ -76,7 +83,7 @@ final class RemoteSnapshotMetadata
public MavenMetadata setFile( File file )
{
return new RemoteSnapshotMetadata( metadata, file );
return new RemoteSnapshotMetadata( metadata, file, legacyFormat );
}
public Object getKey()
@ -156,8 +163,11 @@ final class RemoteSnapshotMetadata
}
}
if ( !legacyFormat )
{
metadata.getVersioning().setSnapshotVersions( new ArrayList<SnapshotVersion>( versions.values() ) );
}
}
private String getKey( String classifier, String extension )
{

View File

@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.sonatype.aether.ConfigurationProperties;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.deployment.DeployRequest;
@ -37,10 +38,14 @@ class RemoteSnapshotMetadataGenerator
implements MetadataGenerator
{
private Map<Object, RemoteSnapshotMetadata> snapshots;
private final Map<Object, RemoteSnapshotMetadata> snapshots;
private final boolean legacyFormat;
public RemoteSnapshotMetadataGenerator( RepositorySystemSession session, DeployRequest request )
{
legacyFormat = ConfigurationProperties.get( session.getConfigProperties(), "maven.metadata.legacy", false );
snapshots = new LinkedHashMap<Object, RemoteSnapshotMetadata>();
/*
@ -69,7 +74,7 @@ class RemoteSnapshotMetadataGenerator
RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key );
if ( snapshotMetadata == null )
{
snapshotMetadata = new RemoteSnapshotMetadata( artifact );
snapshotMetadata = new RemoteSnapshotMetadata( artifact, legacyFormat );
snapshots.put( key, snapshotMetadata );
}
snapshotMetadata.bind( artifact );

View File

@ -56,7 +56,6 @@ final class VersionsMetadata
}
Metadata metadata = new Metadata();
metadata.setModelVersion( "1.0.0" );
metadata.setVersioning( versioning );
metadata.setGroupId( artifact.getGroupId() );
metadata.setArtifactId( artifact.getArtifactId() );