[MNG-4952] [regression] RELEASE field of repository metadata is not updated upon repeated deployments

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1054683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2011-01-03 16:56:51 +00:00
parent 12649ae4a7
commit acd646e4a4
2 changed files with 27 additions and 19 deletions

View File

@ -25,7 +25,6 @@ import java.io.Reader;
import java.io.Writer;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
import org.codehaus.plexus.util.IOUtil;
@ -81,24 +80,7 @@ abstract class MavenMetadata
return merged;
}
protected void merge( Metadata recessive )
{
Versioning versioning = recessive.getVersioning();
if ( versioning != null )
{
versioning.setLastUpdated( null );
}
Metadata dominant = metadata;
versioning = dominant.getVersioning();
if ( versioning != null )
{
versioning.updateTimestamp();
}
dominant.merge( recessive );
}
protected abstract void merge( Metadata recessive );
private Metadata read( File metadataFile )
throws RepositoryException

View File

@ -20,6 +20,9 @@ package org.apache.maven.repository.internal;
*/
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
@ -68,6 +71,29 @@ final class VersionsMetadata
return metadata;
}
@Override
protected void merge( Metadata recessive )
{
Versioning versioning = metadata.getVersioning();
versioning.updateTimestamp();
if ( recessive.getVersioning() != null )
{
if ( versioning.getLatest() == null )
{
versioning.setLatest( recessive.getVersioning().getLatest() );
}
if ( versioning.getRelease() == null )
{
versioning.setRelease( recessive.getVersioning().getRelease() );
}
Collection<String> versions = new LinkedHashSet<String>( recessive.getVersioning().getVersions() );
versions.addAll( versioning.getVersions() );
versioning.setVersions( new ArrayList<String>( versions ) );
}
}
public Object getKey()
{
return getGroupId() + ':' + getArtifactId();