You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ca...@apache.org on 2007/08/20 16:44:02 UTC

svn commit: r567719 - in /maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver: DefaultArtifactResolver.java MultipleArtifactsNotFoundException.java

Author: carlos
Date: Mon Aug 20 07:44:01 2007
New Revision: 567719

URL: http://svn.apache.org/viewvc?rev=567719&view=rev
Log:
Merged 566134-566135 from https://svn.apache.org/repos/asf/maven/components/trunk/maven-artifact
Add resolved artifacts to MutipleArtifactsNotFoundException
Add a check for null files in system dependencies

Modified:
    maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
    maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java

Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?rev=567719&r1=567718&r2=567719&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java (original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java Mon Aug 20 07:44:01 2007
@@ -89,6 +89,12 @@
             {
                 File systemFile = artifact.getFile();
 
+                if ( systemFile == null )
+                {
+                    throw new ArtifactNotFoundException(
+                        "System artifact: " + artifact + " has no file attached", artifact );
+                }
+
                 if ( !systemFile.exists() )
                 {
                     throw new ArtifactNotFoundException(
@@ -285,6 +291,7 @@
                                                               localRepository, remoteRepositories, source, filter,
                                                               listeners );
 
+        List resolvedArtifacts = new ArrayList();
         List missingArtifacts = new ArrayList();
         for ( Iterator i = artifactResolutionResult.getArtifactResolutionNodes().iterator(); i.hasNext(); )
         {
@@ -292,6 +299,7 @@
             try
             {
                 resolve( node.getArtifact(), node.getRemoteRepositories(), localRepository );
+                resolvedArtifacts.add( node.getArtifact() );
             }
             catch ( ArtifactNotFoundException anfe )
             {
@@ -303,7 +311,8 @@
 
         if ( missingArtifacts.size() > 0 )
         {
-            throw new MultipleArtifactsNotFoundException( originatingArtifact, missingArtifacts, remoteRepositories );
+            throw new MultipleArtifactsNotFoundException( originatingArtifact, resolvedArtifacts, missingArtifacts,
+                                                          remoteRepositories );
         }
 
         return artifactResolutionResult;

Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java?rev=567719&r1=567718&r2=567719&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java (original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.java Mon Aug 20 07:44:01 2007
@@ -19,22 +19,59 @@
  * under the License.
  */
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
 import org.apache.maven.artifact.Artifact;
 
+/**
+ * Exception caused when one or more artifacts can not be resolved because they are not found in the
+ * local or remote repositories.
+ */
 public class MultipleArtifactsNotFoundException
     extends ArtifactResolutionException
 {
+    private final List resolvedArtifacts;
     private final List missingArtifacts;
     
-    public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List artifacts, List remoteRepositories )
+    /**
+     * @deprecated use {@link #MultipleArtifactsNotFoundException(Artifact, List, List, List)} 
+     */
+    public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List missingArtifacts, List remoteRepositories )
     {
-        super( constructMessage( artifacts ), originatingArtifact, remoteRepositories );
-        this.missingArtifacts = artifacts;
+        this( originatingArtifact, new ArrayList(), missingArtifacts, remoteRepositories );
+    }
+
+    /**
+     * Create an instance of the exception with allrequired information.
+     * 
+     * @param originatingArtifact the artifact that was being resolved
+     * @param resolvedArtifacts artifacts that could be resolved
+     * @param missingArtifacts artifacts that could not be resolved
+     * @param remoteRepositories remote repositories where the missing artifacts were not found
+     */
+    public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List resolvedArtifacts,
+                                               List missingArtifacts, List remoteRepositories )
+    {
+        super( constructMessage( missingArtifacts ), originatingArtifact, remoteRepositories );
+        this.resolvedArtifacts = resolvedArtifacts;
+        this.missingArtifacts = missingArtifacts;
+    }
+
+    /**
+     * artifacts that could be resolved
+     * @return {@link List} of {@link Artifact}
+     */
+    public List getResolvedArtifacts()
+    {
+        return resolvedArtifacts;
     }
     
+    /**
+     * artifacts that could NOT be resolved
+     * @return {@link List} of {@link Artifact}
+     */
     public List getMissingArtifacts()
     {
         return missingArtifacts;