[MNG-4452] Metadata for snapshots should include classifier

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@995057 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-09-08 13:48:04 +00:00
parent 1abc9c1e9a
commit 01ae5291a8
3 changed files with 40 additions and 12 deletions

View File

@ -235,7 +235,7 @@ public class DefaultVersionResolver
}
else
{
if ( !resolve( result, infos, SNAPSHOT + artifact.getClassifier() )
if ( !resolve( result, infos, SNAPSHOT + getKey( artifact.getClassifier(), artifact.getExtension() ) )
&& !resolve( result, infos, SNAPSHOT ) )
{
result.setVersion( version );
@ -322,18 +322,17 @@ public class DefaultVersionResolver
merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );
}
boolean mainSnapshot = false;
for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
{
if ( StringUtils.isNotEmpty( sv.getVersion() ) )
{
mainSnapshot |= sv.getClassifier().length() <= 0;
merge( SNAPSHOT + sv.getClassifier(), infos, sv.getUpdated(), sv.getVersion(), repository );
String key = getKey( sv.getClassifier(), sv.getExtension() );
merge( SNAPSHOT + key, infos, sv.getUpdated(), sv.getVersion(), repository );
}
}
Snapshot snapshot = versioning.getSnapshot();
if ( !mainSnapshot && snapshot != null )
if ( snapshot != null )
{
String version = artifact.getVersion();
if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
@ -361,6 +360,11 @@ public class DefaultVersionResolver
}
}
private String getKey( String classifier, String extension )
{
return StringUtils.clean( classifier ) + ':' + StringUtils.clean( extension );
}
private static class VersionInfo
{
@ -391,6 +395,10 @@ public class DefaultVersionResolver
private final String artifactId;
private final String classifier;
private final String extension;
private final String version;
private final String context;
@ -405,9 +413,12 @@ public class DefaultVersionResolver
public Key( RepositorySystemSession session, VersionRequest request )
{
groupId = request.getArtifact().getGroupId();
artifactId = request.getArtifact().getArtifactId();
version = request.getArtifact().getVersion();
Artifact artifact = request.getArtifact();
groupId = artifact.getGroupId();
artifactId = artifact.getArtifactId();
classifier = artifact.getClassifier();
extension = artifact.getExtension();
version = artifact.getVersion();
context = request.getRequestContext();
localRepo = session.getLocalRepository().getBasedir();
workspace = CacheUtils.getWorkspace( session );
@ -427,6 +438,8 @@ public class DefaultVersionResolver
int hash = 17;
hash = hash * 31 + groupId.hashCode();
hash = hash * 31 + artifactId.hashCode();
hash = hash * 31 + classifier.hashCode();
hash = hash * 31 + extension.hashCode();
hash = hash * 31 + version.hashCode();
hash = hash * 31 + localRepo.hashCode();
hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
@ -447,6 +460,7 @@ public class DefaultVersionResolver
Key that = (Key) obj;
return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId )
&& classifier.equals( that.classifier ) && extension.equals( that.extension )
&& version.equals( that.version ) && context.equals( that.context )
&& localRepo.equals( that.localRepo ) && CacheUtils.eq( workspace, that.workspace )
&& CacheUtils.repositoriesEquals( repositories, that.repositories );

View File

@ -91,7 +91,8 @@ final class RemoteSnapshotMetadata
public String getExpandedVersion( Artifact artifact )
{
return versions.get( artifact.getClassifier() ).getVersion();
String key = getKey( artifact.getClassifier(), artifact.getExtension() );
return versions.get( key ).getVersion();
}
@Override
@ -134,9 +135,10 @@ final class RemoteSnapshotMetadata
SnapshotVersion sv = new SnapshotVersion();
sv.setClassifier( artifact.getClassifier() );
sv.setExtension( artifact.getExtension() );
sv.setVersion( version );
sv.setUpdated( lastUpdated );
versions.put( sv.getClassifier(), sv );
versions.put( getKey( sv.getClassifier(), sv.getExtension() ), sv );
}
artifacts.clear();
@ -146,9 +148,10 @@ final class RemoteSnapshotMetadata
{
for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
{
if ( !versions.containsKey( sv.getClassifier() ) )
String key = getKey( sv.getClassifier(), sv.getExtension() );
if ( !versions.containsKey( key ) )
{
versions.put( sv.getClassifier(), sv );
versions.put( key, sv );
}
}
}
@ -156,6 +159,11 @@ final class RemoteSnapshotMetadata
metadata.getVersioning().setSnapshotVersions( new ArrayList<SnapshotVersion>( versions.values() ) );
}
private String getKey( String classifier, String extension )
{
return classifier + ':' + extension;
}
private static int getBuildNumber( Metadata metadata )
{
int number = 0;

View File

@ -312,6 +312,12 @@ under the License.
<description>The classifier of the snapshot artifact this version information belongs to.</description>
<defaultValue></defaultValue>
</field>
<field>
<name>extension</name>
<version>1.1.0+</version>
<type>String</type>
<description>The file extension of the snapshot artifact this version information belongs to.</description>
</field>
<field xml.tagName="value">
<name>version</name>
<version>1.1.0+</version>