maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r749460 - in /maven/components/trunk: maven-compat/src/main/java/org/apache/maven/artifact/resolver/ maven-project/src/main/java/org/apache/maven/project/ maven-project/src/test/java/org/apache/maven/project/
Date Mon, 02 Mar 2009 22:40:17 GMT
Author: jvanzyl
Date: Mon Mar  2 22:40:17 2009
New Revision: 749460

URL: http://svn.apache.org/viewvc?rev=749460&view=rev
Log:
o fixing failing project building tests as a result of consolidating the artifact resolution
code

Modified:
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java?rev=749460&r1=749459&r2=749460&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionRequest.java
Mon Mar  2 22:40:17 2009
@@ -233,12 +233,17 @@
     public String toString()
     {
         StringBuffer sb = new StringBuffer()
+                .append( "REQUEST: " ).append(  "\n" )
                 .append(getGroupId())
                 .append(":")
                 .append(getArtifactId())
                 .append(":")
-                .append(getVersion());
-
+                .append(getVersion() ).append(  "\n" )
+                .append(  "artifact: " ).append( artifact ).append(  "\n" )
+                .append( "localRepository: " ).append(  localRepository ).append(  "\n" )
+                .append( "remoteRepositories: " ).append(  remoteRepositories ).append( 
"\n" )
+                .append( "metadataSource: " ).append(  metadataSource ).append(  "\n" );
+        
         return sb.toString();
     }
 }

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java?rev=749460&r1=749459&r2=749460&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
Mon Mar  2 22:40:17 2009
@@ -49,12 +49,17 @@
 {
     private Artifact originatingArtifact;
 
+
+    private List<Artifact> missingArtifacts;
+
+    // Exceptions
+
+    private List<Exception> exceptions = new ArrayList<Exception>();
+    
     private List<Exception> versionRangeViolations;
 
     private List<ArtifactResolutionException> metadataResolutionExceptions;
 
-    private List<Artifact> missingArtifacts;
-
     private List<CyclicDependencyException> circularDependencyExceptions;
 
     private List<ArtifactResolutionException> errorArtifactExceptions;
@@ -129,7 +134,21 @@
 
         return this;
     }
-
+    
+    // ------------------------------------------------------------------------
+    // Exceptions
+    // ------------------------------------------------------------------------
+    
+    public boolean hasExceptions()
+    {
+        return exceptions.size() > 0;
+    }
+    
+    public List<Exception> getExceptions()
+    {        
+        return exceptions;
+    }
+    
     // ------------------------------------------------------------------------
     // Version Range Violations
     // ------------------------------------------------------------------------
@@ -149,6 +168,8 @@
         versionRangeViolations = initList( versionRangeViolations );
 
         versionRangeViolations.add( e );
+        
+        exceptions.add( e );
 
         return this;
     }
@@ -177,6 +198,8 @@
         metadataResolutionExceptions = initList( metadataResolutionExceptions );
 
         metadataResolutionExceptions.add( e );
+        
+        exceptions.add( e );
 
         return this;
     }
@@ -205,6 +228,8 @@
         errorArtifactExceptions = initList( errorArtifactExceptions );
 
         errorArtifactExceptions.add( e );
+        
+        exceptions.add( e );
 
         return this;
     }
@@ -232,6 +257,8 @@
         circularDependencyExceptions = initList( circularDependencyExceptions );
 
         circularDependencyExceptions.add( e );
+        
+        exceptions.add( e );
 
         return this;
     }

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?rev=749460&r1=749459&r2=749460&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
Mon Mar  2 22:40:17 2009
@@ -376,6 +376,28 @@
             listeners.add( new WarningResolutionListener( getLogger() ) );
         }
                 
+        if ( request.getArtifactDependencies() == null || request.getArtifactDependencies().size()
== 0 )
+        {
+            ArtifactResolutionResult result = new ArtifactResolutionResult();
+            
+            try
+            {
+                resolve( request.getArtifact(), request.getRemoteRepostories(), request.getLocalRepository()
);
+                
+                result.addArtifact( request.getArtifact() );
+            }
+            catch ( ArtifactResolutionException e )
+            {
+                result.addErrorArtifactException( e );
+            }
+            catch ( ArtifactNotFoundException e )
+            {
+                result.addMissingArtifact( request.getArtifact() );
+            }
+            
+            return result;
+        }
+        
         // After the collection we will have the artifact object in the result but they will
not be resolved yet.
         ArtifactResolutionResult result = artifactCollector.collect( artifacts, originatingArtifact,
managedVersions, localRepository, remoteRepositories, source, filter, listeners );
 

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=749460&r1=749459&r2=749460&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Mon Mar  2 22:40:17 2009
@@ -303,7 +303,7 @@
                                                 "Unable to build project due to an invalid
dependency version: " +
                                                     e.getMessage(), projectDescriptor, ee
);
         }
-
+        
         ArtifactResolutionRequest request = new ArtifactResolutionRequest()
             .setArtifact( project.getArtifact() )
             .setArtifactDependencies( project.getDependencyArtifacts() )
@@ -311,9 +311,18 @@
             .setRemoteRepostories( project.getRemoteArtifactRepositories() )
             .setManagedVersionMap( project.getManagedVersionMap() )
             .setMetadataSource( repositorySystem );
-
+        
         ArtifactResolutionResult result = repositorySystem.resolve( request );
                 
+        if ( result.hasExceptions() )
+        {
+            Exception e = result.getExceptions().get( 0 );
+            
+            throw new ProjectBuildingException( safeVersionlessKey( project.getGroupId(),
project.getArtifactId() ),
+                                                "Unable to build project due to an invalid
dependency version: " +
+                                                    e.getMessage(), projectDescriptor, e
);
+        }
+        
         project.setArtifacts( result.getArtifacts() );
 
         return new MavenProjectBuildingResult( project, result );

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java?rev=749460&r1=749459&r2=749460&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
(original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java
Mon Mar  2 22:40:17 2009
@@ -19,7 +19,6 @@
  * under the License.
  */
 
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.HashSet;
@@ -33,15 +32,10 @@
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.metadata.ResolutionGroup;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
@@ -125,8 +119,7 @@
             List artifactRepositories;
             try
             {
-                artifactRepositories =
-                    repositorySystem.buildArtifactRepositories( model.getRepositories() );
+                artifactRepositories = repositorySystem.buildArtifactRepositories( model.getRepositories()
);
             }
             catch ( InvalidRepositoryException e )
             {
@@ -199,34 +192,4 @@
     {
         return new Source( repositorySystem, container );
     }
-
-    /**
-     * @noinspection RefusedBequest
-     */
-    @Override
-    public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository
)
-        throws ArtifactResolutionException
-    {
-        artifact.setFile( new File( "dummy" ) );
-    }
-
-    @Override
-    public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
-                                                         ArtifactRepository localRepository,
List remoteRepositories,
-                                                         ArtifactMetadataSource source, ArtifactFilter
filter )
-        throws ArtifactResolutionException, ArtifactNotFoundException
-    {
-        return super.resolveTransitively( artifacts, originatingArtifact, localRepository,
remoteRepositories,
-                                          new Source( repositorySystem, container ), filter
);
-    }
-
-    @Override
-    public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
-                                                         List remoteRepositories, ArtifactRepository
localRepository,
-                                                         ArtifactMetadataSource source )
-        throws ArtifactResolutionException, ArtifactNotFoundException
-    {
-        return super.resolveTransitively( artifacts, originatingArtifact, remoteRepositories,
localRepository,
-                                          new Source( repositorySystem, container ) );
-    }
 }
\ No newline at end of file

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java?rev=749460&r1=749459&r2=749460&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java
(original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java
Mon Mar  2 22:40:17 2009
@@ -29,9 +29,5 @@
     extends DefaultMavenProjectBuilder
 {
     @Requirement(hint="test")
-    private ArtifactResolver artifactResolver;
-    
-    // Causing problems
-    //@Requirement(hint="test")
-    //private MavenRepositorySystem repositorySystem;        
+    private ArtifactResolver artifactResolver;    
 }



Mime
View raw message