mirror of https://github.com/apache/maven.git
honour an installed SNAPSHOT in favour of the remote version, until a newer remote version is deployed
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163713 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8fc9b6db13
commit
e622d5e323
|
@ -82,6 +82,7 @@ public abstract class AbstractArtifactRepositoryLayout
|
|||
ArtifactHandler artifactHandler = null;
|
||||
try
|
||||
{
|
||||
// TODO: this is a poor excuse to have this method throwing an exception. Validate the artifact first, perhaps associate the handler with it
|
||||
artifactHandler = artifactHandlerManager.getArtifactHandler( artifact.getType() );
|
||||
}
|
||||
catch ( ArtifactHandlerNotFoundException e )
|
||||
|
|
|
@ -77,6 +77,19 @@ public class DefaultArtifactResolver
|
|||
logger.debug( "Resolving: " + artifact.getId() + " from:\n" + "{localRepository: " + localRepository + "}\n" +
|
||||
"{remoteRepositories: " + remoteRepositories + "}" );
|
||||
|
||||
String localPath;
|
||||
|
||||
try
|
||||
{
|
||||
localPath = localRepository.pathOf( artifact );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Error resolving artifact: ", e );
|
||||
}
|
||||
|
||||
artifact.setFile( new File( localRepository.getBasedir(), localPath ) );
|
||||
|
||||
// TODO: better to have a transform manager, or reuse the handler manager again so we don't have these requirements duplicated all over?
|
||||
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
||||
{
|
||||
|
@ -91,20 +104,7 @@ public class DefaultArtifactResolver
|
|||
}
|
||||
}
|
||||
|
||||
String localPath;
|
||||
|
||||
try
|
||||
{
|
||||
localPath = localRepository.pathOf( artifact );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Error resolving artifact: ", e );
|
||||
}
|
||||
|
||||
File destination = new File( localRepository.getBasedir(), localPath );
|
||||
artifact.setFile( destination );
|
||||
|
||||
File destination = artifact.getFile();
|
||||
if ( !destination.exists() )
|
||||
{
|
||||
try
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
@ -54,9 +55,6 @@ public class SnapshotTransformation
|
|||
{
|
||||
if ( isSnapshot( artifact ) )
|
||||
{
|
||||
// TODO: this mostly works, however...
|
||||
// - we definitely need the manual/daily check as this is quite slow given the large number of snapshots inside m2 presently
|
||||
|
||||
SnapshotArtifactMetadata localMetadata;
|
||||
try
|
||||
{
|
||||
|
@ -72,7 +70,8 @@ public class SnapshotTransformation
|
|||
}
|
||||
|
||||
String version = localMetadata.constructVersion();
|
||||
if ( !alreadyResolved( artifact ) )
|
||||
boolean alreadyResolved = alreadyResolved( artifact );
|
||||
if ( !alreadyResolved )
|
||||
{
|
||||
boolean checkedUpdates = false;
|
||||
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
|
||||
|
@ -131,9 +130,23 @@ public class SnapshotTransformation
|
|||
localMetadata.storeInLocalRepository( localRepository );
|
||||
}
|
||||
|
||||
resolvedArtifactCache.add( getCacheKey( artifact ) );
|
||||
}
|
||||
|
||||
// TODO: if the POM and JAR are inconsistent, this might mean that different version of each are used
|
||||
if ( artifact.getFile().exists() && artifact.getFile().lastModified() > localMetadata.getLastModified() )
|
||||
{
|
||||
if ( !alreadyResolved )
|
||||
{
|
||||
// Locally installed file is newer, don't use the resolved version
|
||||
getLogger().info( artifact.getArtifactId() + ": using locally installed snapshot" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( getLogger().isInfoEnabled() )
|
||||
{
|
||||
if ( !version.equals( artifact.getBaseVersion() ) )
|
||||
if ( !version.equals( artifact.getBaseVersion() ) && !alreadyResolved )
|
||||
{
|
||||
String message = artifact.getArtifactId() + ": resolved to version " + version;
|
||||
if ( artifact.getRepository() != null )
|
||||
|
@ -148,9 +161,16 @@ public class SnapshotTransformation
|
|||
}
|
||||
}
|
||||
|
||||
resolvedArtifactCache.add( getCacheKey( artifact ) );
|
||||
}
|
||||
artifact.setVersion( version );
|
||||
try
|
||||
{
|
||||
artifact.setFile( new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ) );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue