diff --git a/maven-artifact-manager/pom.xml b/maven-artifact-manager/pom.xml index 5affeae270..5140baa6e0 100644 --- a/maven-artifact-manager/pom.xml +++ b/maven-artifact-manager/pom.xml @@ -22,6 +22,11 @@ plexus-container-default 1.0-alpha-4 + + plexus + plexus-utils + 1.0.2-SNAPSHOT + org.apache.maven.wagon wagon-provider-api diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java index da91895a4d..40506c7578 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java @@ -244,6 +244,8 @@ public class DefaultWagonManager if ( policy.isEnabled() ) { getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy() ); + + artifact.setResolved( true ); } else { diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java index fa1f8f7daa..f0f0ff5bd8 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java @@ -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 ); + } } } diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java b/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java index 799bce7ce4..37669ed6f4 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java @@ -128,5 +128,9 @@ public interface Artifact void setArtifactId( String artifactId ); boolean isSnapshot(); + + void setResolved( boolean resolved ); + + boolean isResolved(); } \ No newline at end of file diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java b/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java index ea4b5f23a8..26f0fef531 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java @@ -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; + } + } diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java index 49fbfd1c48..1678e23e8d 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.java @@ -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, diff --git a/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java b/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java index de9c50c226..2c0cdfd5d9 100644 --- a/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java +++ b/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java @@ -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(); + } }