mirror of https://github.com/apache/maven.git
Adding resolved flag to Artifact.
This is done to counter the possibility that an artifact's file is set without the artifact actually being resolved, as in the case where the artifact is a snapshot version, but no snapshot-enabled repositories exist (think plugin resolution). This also has the beneficial side-effect of providing a more intuitive method of checking whether an artifact has been resolved (rather than artifact.getFile() != null). git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@226333 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ebbf8db6f8
commit
a6891c4e25
|
@ -22,6 +22,11 @@
|
|||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>1.0-alpha-4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-provider-api</artifactId>
|
||||
|
|
|
@ -244,6 +244,8 @@ public class DefaultWagonManager
|
|||
if ( policy.isEnabled() )
|
||||
{
|
||||
getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy() );
|
||||
|
||||
artifact.setResolved( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -114,6 +114,11 @@ public class DefaultArtifactResolver
|
|||
{
|
||||
wagonManager.getArtifact( artifact, remoteRepositories );
|
||||
}
|
||||
|
||||
if ( !artifact.isResolved() )
|
||||
{
|
||||
throw new ArtifactResolutionException( "Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.", artifact, remoteRepositories );
|
||||
}
|
||||
|
||||
// must be after the artifact is downloaded
|
||||
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
|
||||
|
@ -135,6 +140,11 @@ public class DefaultArtifactResolver
|
|||
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
|
||||
}
|
||||
}
|
||||
else if ( destination.exists() )
|
||||
{
|
||||
// locally resolved...no need to hit the remote repo.
|
||||
artifact.setResolved( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,5 +128,9 @@ public interface Artifact
|
|||
void setArtifactId( String artifactId );
|
||||
|
||||
boolean isSnapshot();
|
||||
|
||||
void setResolved( boolean resolved );
|
||||
|
||||
boolean isResolved();
|
||||
|
||||
}
|
|
@ -72,6 +72,8 @@ public class DefaultArtifact
|
|||
|
||||
private VersionRange versionRange;
|
||||
|
||||
private boolean resolved = false;
|
||||
|
||||
public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type,
|
||||
String classifier, ArtifactHandler artifactHandler )
|
||||
{
|
||||
|
@ -436,4 +438,14 @@ public class DefaultArtifact
|
|||
}
|
||||
}
|
||||
|
||||
public void setResolved( boolean resolved )
|
||||
{
|
||||
this.resolved = resolved;
|
||||
}
|
||||
|
||||
public boolean isResolved()
|
||||
{
|
||||
return resolved;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -150,6 +150,12 @@ public class ArtifactResolutionException
|
|||
remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail(), t );
|
||||
}
|
||||
|
||||
public ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories )
|
||||
{
|
||||
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(),
|
||||
remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail() );
|
||||
}
|
||||
|
||||
public ArtifactResolutionException( String message, Artifact artifact )
|
||||
{
|
||||
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), null,
|
||||
|
|
|
@ -220,4 +220,14 @@ public class ActiveProjectArtifact
|
|||
{
|
||||
return artifact.compareTo( o );
|
||||
}
|
||||
|
||||
public void setResolved( boolean resolved )
|
||||
{
|
||||
artifact.setResolved( resolved );
|
||||
}
|
||||
|
||||
public boolean isResolved()
|
||||
{
|
||||
return artifact.isResolved();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue