maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject [maven-project-info-reports-plugin] 01/02: [MPIR-366] Replace ArtifactResolver
Date Fri, 30 Mar 2018 19:00:30 GMT
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch MPIR-366
in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git

commit 824e67f448af645b50143a931fa9f379fed34bd7
Author: rfscholte <rfscholte@apache.org>
AuthorDate: Fri Mar 30 14:37:25 2018 +0200

    [MPIR-366] Replace ArtifactResolver
---
 pom.xml                                            |  6 ++++++
 .../projectinfo/AbstractProjectInfoReport.java     |  2 +-
 .../projectinfo/dependencies/RepositoryUtils.java  | 25 +++++++++++-----------
 .../renderer/DependenciesRenderer.java             | 12 +++--------
 4 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/pom.xml b/pom.xml
index 933cfc0..c4a01bb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -201,6 +201,12 @@ under the License.
       <artifactId>maven-common-artifact-filters</artifactId>
       <version>3.0.1</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-artifact-transfer</artifactId>
+      <version>0.9.1</version>
+    </dependency>
+    
 
     <!-- Wagon -->
     <dependency>
diff --git a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
index 6c1ecf7..9a033e9 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
@@ -39,7 +39,6 @@ import java.util.ResourceBundle;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.doxia.site.decoration.Body;
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.siterenderer.Renderer;
@@ -59,6 +58,7 @@ import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
 import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolver;
 import org.codehaus.plexus.i18n.I18N;
 import org.codehaus.plexus.interpolation.EnvarBasedValueSource;
 import org.codehaus.plexus.interpolation.InterpolationException;
diff --git a/src/main/java/org/apache/maven/report/projectinfo/dependencies/RepositoryUtils.java
b/src/main/java/org/apache/maven/report/projectinfo/dependencies/RepositoryUtils.java
index 743229a..bdebb78 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/dependencies/RepositoryUtils.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/dependencies/RepositoryUtils.java
@@ -33,10 +33,8 @@ import org.apache.maven.artifact.repository.metadata.Metadata;
 import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
 import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
 import org.apache.maven.artifact.repository.metadata.Versioning;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
@@ -44,6 +42,9 @@ import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.repository.legacy.WagonConfigurationException;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.artifact.resolve.ArtifactResult;
 import org.apache.maven.wagon.ConnectionException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.UnsupportedProtocolException;
@@ -139,19 +140,21 @@ public class RepositoryUtils
 
     /**
      * @param artifact not null
-     * @throws ArtifactResolutionException if any
-     * @throws ArtifactNotFoundException if any
-     * @see ArtifactResolver#resolve(Artifact, List, ArtifactRepository)
+     * @throws ArtifactResolverException if any 
      */
     public void resolve( Artifact artifact )
-        throws ArtifactResolutionException, ArtifactNotFoundException
+        throws ArtifactResolverException
     {
         List<ArtifactRepository> repos =
             new ArrayList<ArtifactRepository>( pluginRepositories.size() + remoteRepositories.size()
);
         repos.addAll( pluginRepositories );
         repos.addAll( remoteRepositories );
+        
+        ProjectBuildingRequest buildRequest = new DefaultProjectBuildingRequest( buildingRequest
);
+        buildRequest.setRemoteRepositories( repos );
 
-        resolver.resolve( artifact, repos, getLocalRepository() );
+        ArtifactResult result = resolver.resolveArtifact( buildRequest , artifact );
+        artifact.setFile( result.getArtifact().getFile() );
     }
 
     /**
@@ -324,14 +327,10 @@ public class RepositoryUtils
                     {
                         resolve( artifact );
                     }
-                    catch ( ArtifactResolutionException e )
+                    catch ( ArtifactResolverException e )
                     {
                         log.error( "Artifact: " + artifact.getId() + " could not be resolved."
);
                     }
-                    catch ( ArtifactNotFoundException e )
-                    {
-                        log.error( "Artifact: " + artifact.getId() + " was not found." );
-                    }
                 }
 
                 for ( ArtifactMetadata m : artifact.getMetadataList() )
diff --git a/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java
b/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java
index cc661cc..fb19a37 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java
@@ -45,8 +45,6 @@ import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkEventAttributeSet;
 import org.apache.maven.doxia.sink.SinkEventAttributes;
@@ -63,6 +61,7 @@ import org.apache.maven.report.projectinfo.dependencies.Dependencies;
 import org.apache.maven.report.projectinfo.dependencies.DependenciesReportConfiguration;
 import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils;
 import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
 import org.apache.maven.shared.dependency.graph.DependencyNode;
 import org.apache.maven.shared.jar.JarData;
 import org.codehaus.plexus.i18n.I18N;
@@ -1275,12 +1274,7 @@ public class DependenciesRenderer
                 {
                     repoUtils.resolve( artifact );
                 }
-                catch ( ArtifactResolutionException e )
-                {
-                    log.error( "Artifact " + artifact.getId() + " can't be resolved.", e
);
-                    continue;
-                }
-                catch ( ArtifactNotFoundException e )
+                catch ( ArtifactResolverException e )
                 {
                     if ( ( dependencies.getProject().getGroupId().equals( artifact.getGroupId()
) )
                         && ( dependencies.getProject().getArtifactId().equals( artifact.getArtifactId()
) )
@@ -1290,7 +1284,7 @@ public class DependenciesRenderer
                     }
                     else
                     {
-                        log.error( "Artifact " + artifact.getId() + " not found.", e );
+                        log.error( "Artifact " + artifact.getId() + " can't be resolved.",
e );
                     }
 
                     continue;

-- 
To stop receiving notification emails like this one, please contact
rfscholte@apache.org.

Mime
View raw message