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] branch MPIR-366 updated: [MPIR-366] Replace MavenProjectBuilder with ProjectBuilder
Date Fri, 30 Mar 2018 12:01:01 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


The following commit(s) were added to refs/heads/MPIR-366 by this push:
     new a4b740a  [MPIR-366] Replace MavenProjectBuilder with ProjectBuilder
a4b740a is described below

commit a4b740a2a138e75ebf217b442b214e5049b1d545
Author: rfscholte <rfscholte@apache.org>
AuthorDate: Fri Mar 30 14:00:46 2018 +0200

    [MPIR-366] Replace MavenProjectBuilder with ProjectBuilder
---
 .../projectinfo/AbstractProjectInfoReport.java     |  4 +-
 .../report/projectinfo/DependenciesReport.java     | 22 +++++++----
 .../projectinfo/DependencyManagementReport.java    | 23 +++++++----
 .../maven/report/projectinfo/IndexReport.java      |  8 ++--
 .../maven/report/projectinfo/ModulesReport.java    | 17 +++++---
 .../report/projectinfo/PluginManagementReport.java | 43 ++++++++++-----------
 .../maven/report/projectinfo/PluginsReport.java    | 45 ++++++++++++----------
 .../report/projectinfo/ProjectInfoReportUtils.java | 20 ++++------
 .../projectinfo/dependencies/RepositoryUtils.java  | 27 +++++++------
 .../renderer/DependenciesRenderer.java             | 28 ++++++--------
 .../renderer/DependencyManagementRenderer.java     | 29 ++++++--------
 11 files changed, 134 insertions(+), 132 deletions(-)

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 de7bec1..6c1ecf7 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java
@@ -55,7 +55,7 @@ import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
 import org.apache.maven.settings.Settings;
@@ -120,7 +120,7 @@ public abstract class AbstractProjectInfoReport
      * issues like DOXIASITETOOLS-166)
      */
     @Component
-    protected MavenProjectBuilder mavenProjectBuilder;
+    protected ProjectBuilder projectBuilder;
 
     // ----------------------------------------------------------------------
     // Mojo parameters
diff --git a/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java b/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
index 6222329..c52c168 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
@@ -28,6 +28,7 @@ import java.io.InputStreamReader;
 import java.io.LineNumberReader;
 import java.io.OutputStream;
 import java.util.Locale;
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.manager.WagonManager;
@@ -40,7 +41,7 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.DefaultProjectBuildingRequest;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.report.projectinfo.dependencies.Dependencies;
 import org.apache.maven.report.projectinfo.dependencies.DependenciesReportConfiguration;
@@ -78,7 +79,7 @@ public class DependenciesReport
      * Maven Project Builder component.
      */
     @Component
-    private MavenProjectBuilder mavenProjectBuilder;
+    private ProjectBuilder projectBuilder;
 
     /**
      * Artifact metadata source component.
@@ -185,11 +186,16 @@ public class DependenciesReport
         {
             getLog().error( "Cannot copy ressources", e );
         }
-
-        @SuppressWarnings( "unchecked" ) RepositoryUtils repoUtils =
-            new RepositoryUtils( getLog(), wagonManager, settings, mavenProjectBuilder, factory,
resolver,
+        
+        ProjectBuildingRequest buildingRequest =
+            new DefaultProjectBuildingRequest( getSession().getProjectBuildingRequest() );
+        buildingRequest.setLocalRepository( localRepository );
+        buildingRequest.setRemoteRepositories( remoteRepositories );
+
+        RepositoryUtils repoUtils =
+            new RepositoryUtils( getLog(), wagonManager, settings, projectBuilder, factory,
resolver,
                                  project.getRemoteArtifactRepositories(), project.getPluginArtifactRepositories(),
-                                 localRepository, repositoryMetadataManager );
+                                 buildingRequest, repositoryMetadataManager );
 
         DependencyNode dependencyNode = resolveProject();
 
@@ -200,8 +206,8 @@ public class DependenciesReport
 
         DependenciesRenderer r =
             new DependenciesRenderer( getSink(), locale, getI18N( locale ), getLog(), settings,
dependencies,
-                                      dependencyNode, config, repoUtils, artifactFactory,
mavenProjectBuilder,
-                                      remoteRepositories, localRepository );
+                                      dependencyNode, config, repoUtils, artifactFactory,
projectBuilder,
+                                      buildingRequest );
         r.render();
     }
 
diff --git a/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java
b/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java
index e5b990d..7d116c5 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/DependencyManagementReport.java
@@ -19,6 +19,8 @@ package org.apache.maven.report.projectinfo;
  * under the License.
  */
 
+import java.util.Locale;
+
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -26,13 +28,13 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.report.projectinfo.dependencies.ManagementDependencies;
 import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils;
 import org.apache.maven.report.projectinfo.dependencies.renderer.DependencyManagementRenderer;
 
-import java.util.Locale;
-
 /**
  * Generates the Project Dependency Management report.
  *
@@ -52,7 +54,7 @@ public class DependencyManagementReport
      * Maven Project Builder component.
      */
     @Component
-    private MavenProjectBuilder mavenProjectBuilder;
+    private ProjectBuilder projectBuilder;
 
     /**
      * Artifact metadata source component.
@@ -112,15 +114,20 @@ public class DependencyManagementReport
     @Override
     public void executeReport( Locale locale )
     {
-        @SuppressWarnings( "unchecked" ) RepositoryUtils repoUtils =
-            new RepositoryUtils( getLog(), wagonManager, settings, mavenProjectBuilder, factory,
resolver,
+        ProjectBuildingRequest buildingRequest =
+            new DefaultProjectBuildingRequest( getSession().getProjectBuildingRequest() );
+        buildingRequest.setLocalRepository( localRepository );
+        buildingRequest.setRemoteRepositories( remoteRepositories );
+        
+        RepositoryUtils repoUtils =
+            new RepositoryUtils( getLog(), wagonManager, settings, projectBuilder, factory,
resolver,
                                  project.getRemoteArtifactRepositories(), project.getPluginArtifactRepositories(),
-                                 localRepository, repositoryMetadataManager );
+                                 buildingRequest, repositoryMetadataManager );
 
         DependencyManagementRenderer r =
             new DependencyManagementRenderer( getSink(), locale, getI18N( locale ), getLog(),
                                               getManagementDependencies(), artifactMetadataSource,
artifactFactory,
-                                              mavenProjectBuilder, remoteRepositories, localRepository,
repoUtils );
+                                              projectBuilder, buildingRequest, repoUtils
);
         r.render();
     }
 
diff --git a/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java b/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java
index 5c59c1d..3871dbc 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/IndexReport.java
@@ -25,7 +25,7 @@ import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.codehaus.plexus.i18n.I18N;
 
 import java.util.List;
@@ -72,7 +72,7 @@ public class IndexReport
     @Override
     public void executeReport( Locale locale )
     {
-        ProjectIndexRenderer r = new ProjectIndexRenderer( project, getReactorProjects(),
mavenProjectBuilder,
+        ProjectIndexRenderer r = new ProjectIndexRenderer( project, getReactorProjects(),
projectBuilder,
                                                            localRepository, getName( locale
), getDescription( locale ),
                                                            getSink(), getI18N( locale ),
locale, getLog(), siteTool );
 
@@ -108,10 +108,10 @@ public class IndexReport
         private boolean modules = false;
 
         ProjectIndexRenderer( MavenProject project, List<MavenProject> reactorProjects,
-                              MavenProjectBuilder mavenProjectBuilder, ArtifactRepository
localRepository, String title,
+                              ProjectBuilder projectBuilder, ArtifactRepository localRepository,
String title,
                               String description, Sink sink, I18N i18n, Locale locale, Log
log, SiteTool siteTool )
         {
-            super( sink, project, reactorProjects, mavenProjectBuilder, localRepository,
i18n, locale, log, siteTool );
+            super( sink, project, reactorProjects, projectBuilder, localRepository, i18n,
locale, log, siteTool );
 
             this.title = title;
 
diff --git a/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java b/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
index ff0d370..0066cf7 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/ModulesReport.java
@@ -32,9 +32,11 @@ import org.apache.maven.model.DistributionManagement;
 import org.apache.maven.model.Site;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.codehaus.plexus.i18n.I18N;
 
 /**
@@ -67,7 +69,7 @@ public class ModulesReport
     @Override
     public void executeReport( Locale locale )
     {
-        new ModulesRenderer( getSink(), getProject(), getReactorProjects(), mavenProjectBuilder,
localRepository,
+        new ModulesRenderer( getSink(), getProject(), getReactorProjects(), projectBuilder,
localRepository,
                              getI18N( locale ), locale, getLog(), siteTool ).render();
     }
 
@@ -100,21 +102,21 @@ public class ModulesReport
 
         protected List<MavenProject> reactorProjects;
 
-        protected MavenProjectBuilder mavenProjectBuilder;
+        protected ProjectBuilder projectBuilder;
 
         protected ArtifactRepository localRepository;
 
         protected SiteTool siteTool;
 
         ModulesRenderer( Sink sink, MavenProject project, List<MavenProject> reactorProjects,
-                         MavenProjectBuilder mavenProjectBuilder, ArtifactRepository localRepository,
I18N i18n,
+                         ProjectBuilder projectBuilder, ArtifactRepository localRepository,
I18N i18n,
                          Locale locale, Log log, SiteTool siteTool )
         {
             super( sink, i18n, locale );
 
             this.project = project;
             this.reactorProjects = reactorProjects;
-            this.mavenProjectBuilder = mavenProjectBuilder;
+            this.projectBuilder = projectBuilder;
             this.localRepository = localRepository;
             this.siteTool = siteTool;
             this.log = log;
@@ -154,6 +156,9 @@ public class ModulesReport
 
             final String baseUrl = getDistMgmntSiteUrl( project );
 
+            ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
+            buildingRequest.setLocalRepository( localRepository );
+            
             for ( String module : modules )
             {
                 MavenProject moduleProject = getModuleFromReactor( project, reactorProjects,
module );
@@ -167,7 +172,7 @@ public class ModulesReport
                     {
                         try
                         {
-                            moduleProject = mavenProjectBuilder.build( f, localRepository,
null );
+                            moduleProject = projectBuilder.build( f, buildingRequest ).getProject();
                         }
                         catch ( ProjectBuildingException e )
                         {
diff --git a/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
b/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
index 1052ad9..f6696b2 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/PluginManagementReport.java
@@ -21,7 +21,6 @@ package org.apache.maven.report.projectinfo;
 
 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.versioning.VersionRange;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.model.Plugin;
@@ -30,13 +29,14 @@ import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.codehaus.plexus.i18n.I18N;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
@@ -61,7 +61,7 @@ public class PluginManagementReport
      * Maven Project Builder component.
      */
     @Component
-    private MavenProjectBuilder mavenProjectBuilder;
+    private ProjectBuilder projectBuilder;
 
     /**
      * Maven Artifact Factory component.
@@ -78,8 +78,8 @@ public class PluginManagementReport
     {
         PluginManagementRenderer r =
             new PluginManagementRenderer( getLog(), getSink(), locale, getI18N( locale ),
-                                          project.getPluginManagement().getPlugins(), project,
mavenProjectBuilder,
-                                          artifactFactory, localRepository );
+                                          project.getPluginManagement().getPlugins(), project,
projectBuilder,
+                                          artifactFactory, getSession().getProjectBuildingRequest()
);
         r.render();
     }
 
@@ -126,11 +126,11 @@ public class PluginManagementReport
 
         private final MavenProject project;
 
-        private final MavenProjectBuilder mavenProjectBuilder;
+        private final ProjectBuilder projectBuilder;
 
         private final ArtifactFactory artifactFactory;
 
-        private final ArtifactRepository localRepository;
+        private final ProjectBuildingRequest buildingRequest;
 
         /**
          * @param log {@link #log}
@@ -139,13 +139,13 @@ public class PluginManagementReport
          * @param i18n {@link I18N}
          * @param plugins {@link Plugin}
          * @param project {@link MavenProject}
-         * @param mavenProjectBuilder {@link MavenProjectBuilder}
+         * @param projectBuilder {@link ProjectBuilder}
          * @param artifactFactory {@link ArtifactFactory}
-         * @param localRepository {@link ArtifactRepository}
+         * @param buildingRequest {@link ArtifactRepository}
          */
         public PluginManagementRenderer( Log log, Sink sink, Locale locale, I18N i18n, List<Plugin>
plugins,
-                                         MavenProject project, MavenProjectBuilder mavenProjectBuilder,
-                                         ArtifactFactory artifactFactory, ArtifactRepository
localRepository )
+                                         MavenProject project, ProjectBuilder projectBuilder,
+                                         ArtifactFactory artifactFactory, ProjectBuildingRequest
buildingRequest )
         {
             super( sink, i18n, locale );
 
@@ -155,11 +155,11 @@ public class PluginManagementReport
 
             this.project = project;
 
-            this.mavenProjectBuilder = mavenProjectBuilder;
+            this.projectBuilder = projectBuilder;
 
             this.artifactFactory = artifactFactory;
 
-            this.localRepository = localRepository;
+            this.buildingRequest = buildingRequest;
         }
 
         @Override
@@ -201,6 +201,9 @@ public class PluginManagementReport
             startTable();
             tableHeader( tableHeader );
 
+            ProjectBuildingRequest buildRequest = new DefaultProjectBuildingRequest( buildingRequest
);
+            buildRequest.setRemoteRepositories( project.getPluginArtifactRepositories() );
+            
             for ( Plugin plugin : pluginManagement )
             {
                 VersionRange versionRange;
@@ -215,17 +218,11 @@ public class PluginManagementReport
 
                 Artifact pluginArtifact = artifactFactory.createParentArtifact( plugin.getGroupId(),
plugin
                     .getArtifactId(), versionRange.toString() );
-                @SuppressWarnings( "unchecked" )
-                List<ArtifactRepository> artifactRepositories = project.getPluginArtifactRepositories();
-                if ( artifactRepositories == null )
-                {
-                    artifactRepositories = new ArrayList<ArtifactRepository>();
-                }
+
                 try
                 {
-                    MavenProject pluginProject = mavenProjectBuilder.buildFromRepository(
pluginArtifact,
-                                                                                        
 artifactRepositories,
-                                                                                        
 localRepository );
+                    MavenProject pluginProject = projectBuilder.build( pluginArtifact, buildingRequest
).getProject();
+                    
                     tableRow( getPluginRow( pluginProject.getGroupId(), pluginProject.getArtifactId(),
pluginProject
                         .getVersion(), pluginProject.getUrl() ) );
                 }
diff --git a/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java b/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java
index a4bc0dd..c77eb5e 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/PluginsReport.java
@@ -36,9 +36,11 @@ import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.codehaus.plexus.i18n.I18N;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -61,7 +63,7 @@ public class PluginsReport
      * Maven Project Builder component.
      */
     @Component
-    private MavenProjectBuilder mavenProjectBuilder;
+    private ProjectBuilder projectBuilder;
 
     /**
      * Maven Artifact Factory component.
@@ -88,11 +90,10 @@ public class PluginsReport
     @Override
     public void executeReport( Locale locale )
     {
-        @SuppressWarnings( "unchecked" )
         PluginsRenderer r =
             new PluginsRenderer( getLog(), getSink(), locale, getI18N( locale ), project.getBuildPlugins(),
-                                 project.getReportPlugins(), project, mavenProjectBuilder,
artifactFactory,
-                                 localRepository );
+                                 project.getReportPlugins(), project, projectBuilder, artifactFactory,
+                                 getSession().getProjectBuildingRequest() );
         r.render();
     }
 
@@ -126,11 +127,11 @@ public class PluginsReport
 
         private final MavenProject project;
 
-        private final MavenProjectBuilder mavenProjectBuilder;
+        private final ProjectBuilder projectBuilder;
 
         private final ArtifactFactory artifactFactory;
 
-        private final ArtifactRepository localRepository;
+        private final ProjectBuildingRequest buildingRequest;
 
         /**
          * @param log {@link #log}
@@ -140,15 +141,15 @@ public class PluginsReport
          * @param plugins {@link Artifact}
          * @param reports {@link Artifact}
          * @param project {@link MavenProject}
-         * @param mavenProjectBuilder {@link MavenProjectBuilder}
+         * @param projectBuilder {@link ProjectBuilder}
          * @param artifactFactory {@link ArtifactFactory}
          * @param localRepository {@link ArtifactRepository}
          *
          */
         public PluginsRenderer( Log log, Sink sink, Locale locale, I18N i18n, List<Plugin>
plugins,
                                 List<ReportPlugin> reports, MavenProject project,
-                                MavenProjectBuilder mavenProjectBuilder, ArtifactFactory
artifactFactory,
-                                ArtifactRepository localRepository )
+                                ProjectBuilder projectBuilder, ArtifactFactory artifactFactory,
+                                ProjectBuildingRequest buildingRequest )
         {
             super( sink, i18n, locale );
 
@@ -160,11 +161,11 @@ public class PluginsReport
 
             this.project = project;
 
-            this.mavenProjectBuilder = mavenProjectBuilder;
+            this.projectBuilder = projectBuilder;
 
             this.artifactFactory = artifactFactory;
 
-            this.localRepository = localRepository;
+            this.buildingRequest = buildingRequest;
         }
 
         @Override
@@ -207,6 +208,15 @@ public class PluginsReport
             startTable();
             tableHeader( tableHeader );
 
+            List<ArtifactRepository> artifactRepositories = project.getPluginArtifactRepositories();
+            if ( artifactRepositories == null )
+            {
+                artifactRepositories = new ArrayList<ArtifactRepository>();
+            }
+
+            ProjectBuildingRequest buildRequest = new DefaultProjectBuildingRequest( buildingRequest
);
+            buildRequest.setRemoteRepositories( artifactRepositories );
+            
             for ( GAV plugin : list )
             {
                 VersionRange versionRange = VersionRange.createFromVersion( plugin.getVersion()
);
@@ -214,17 +224,10 @@ public class PluginsReport
                 Artifact pluginArtifact =
                     artifactFactory.createParentArtifact( plugin.getGroupId(), plugin.getArtifactId(),
                                                           versionRange.toString() );
-                @SuppressWarnings( "unchecked" )
-                List<ArtifactRepository> artifactRepositories = project.getPluginArtifactRepositories();
-                if ( artifactRepositories == null )
-                {
-                    artifactRepositories = new ArrayList<ArtifactRepository>();
-                }
                 try
                 {
-                    MavenProject pluginProject = mavenProjectBuilder.buildFromRepository(
pluginArtifact,
-                                                                                        
 artifactRepositories,
-                                                                                        
 localRepository );
+                    MavenProject pluginProject = projectBuilder.build( pluginArtifact, buildRequest
).getProject();
+
                     tableRow( getPluginRow( pluginProject.getGroupId(), pluginProject.getArtifactId(),
pluginProject
                                             .getVersion(), pluginProject.getUrl() ) );
                 }
diff --git a/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java
b/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java
index 1bdce16..6f09c50 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/ProjectInfoReportUtils.java
@@ -29,8 +29,6 @@ import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.security.cert.X509Certificate;
-import java.util.Collections;
-import java.util.List;
 import java.util.Properties;
 
 import javax.net.ssl.HostnameVerifier;
@@ -47,10 +45,10 @@ import org.apache.commons.validator.routines.UrlValidator;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
 // CHECKSTYLE_OFF: UnusedImports
 import org.apache.maven.reporting.AbstractMavenReportRenderer;
 // CHECKSTYLE_ON: UnusedImports
@@ -214,15 +212,14 @@ public class ProjectInfoReportUtils
     /**
      * @param factory not null
      * @param artifact not null
-     * @param mavenProjectBuilder not null
-     * @param remoteRepositories not null
-     * @param localRepository not null
+     * @param projectBuilder not null
+     * @param buildingRequest not null
      * @return the artifact url or null if an error occurred.
      */
     // CHECKSTYLE_OFF: LineLength
     public static String getArtifactUrl( ArtifactFactory factory, Artifact artifact,
-                                         MavenProjectBuilder mavenProjectBuilder,
-                                         List<ArtifactRepository> remoteRepositories,
ArtifactRepository localRepository )
+                                         ProjectBuilder projectBuilder,
+                                         ProjectBuildingRequest buildingRequest )
     // CHECKSTYLE_ON: LineLength
     {
         if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
@@ -239,10 +236,7 @@ public class ProjectInfoReportUtils
         }
         try
         {
-            MavenProject pluginProject =
-                mavenProjectBuilder.buildFromRepository( copyArtifact,
-                                                         remoteRepositories == null ? Collections.EMPTY_LIST
-                                                                         : remoteRepositories,
localRepository );
+            MavenProject pluginProject = projectBuilder.build( copyArtifact, buildingRequest
).getProject();
 
             if ( isArtifactUrlValid( pluginProject.getUrl() ) )
             {
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 fe6d6b3..743229a 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
@@ -38,8 +38,9 @@ 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.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+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;
@@ -71,7 +72,7 @@ public class RepositoryUtils
 
     private final Settings settings;
 
-    private final MavenProjectBuilder mavenProjectBuilder;
+    private final ProjectBuilder projectBuilder;
 
     private final ArtifactFactory factory;
 
@@ -81,35 +82,35 @@ public class RepositoryUtils
 
     private final ArtifactResolver resolver;
 
-    private final ArtifactRepository localRepository;
+    private final ProjectBuildingRequest buildingRequest;
 
     /**
      * @param log {@link Log}
      * @param wagonManager {@link WagonManager}
      * @param settings {@link Settings}
-     * @param mavenProjectBuilder {@link MavenProjectBuilder}
+     * @param projectBuilder {@link ProjectBuilder}
      * @param factory {@link ArtifactFactory}
      * @param resolver {@link ArtifactResolver}
      * @param remoteRepositories {@link ArtifactRepository}
      * @param pluginRepositories {@link ArtifactRepository}
-     * @param localRepository {@link ArtifactRepository}
+     * @param buildingRequest {@link ProjectBuildingRequest}
      * @param repositoryMetadataManager {@link RepositoryMetadataManager}
      */
     public RepositoryUtils( Log log, WagonManager wagonManager, Settings settings,
-                            MavenProjectBuilder mavenProjectBuilder, ArtifactFactory factory,
+                            ProjectBuilder projectBuilder, ArtifactFactory factory,
                             ArtifactResolver resolver, List<ArtifactRepository> remoteRepositories,
-                            List<ArtifactRepository> pluginRepositories, ArtifactRepository
localRepository,
+                            List<ArtifactRepository> pluginRepositories, ProjectBuildingRequest
buildingRequest,
                             RepositoryMetadataManager repositoryMetadataManager )
     {
         this.log = log;
         this.wagonManager = wagonManager;
         this.settings = settings;
-        this.mavenProjectBuilder = mavenProjectBuilder;
+        this.projectBuilder = projectBuilder;
         this.factory = factory;
         this.resolver = resolver;
         this.remoteRepositories = remoteRepositories;
         this.pluginRepositories = pluginRepositories;
-        this.localRepository = localRepository;
+        this.buildingRequest = buildingRequest;
     }
 
     /**
@@ -117,7 +118,7 @@ public class RepositoryUtils
      */
     public ArtifactRepository getLocalRepository()
     {
-        return localRepository;
+        return buildingRequest.getLocalRepository();
     }
 
     /**
@@ -150,7 +151,7 @@ public class RepositoryUtils
         repos.addAll( pluginRepositories );
         repos.addAll( remoteRepositories );
 
-        resolver.resolve( artifact, repos, localRepository );
+        resolver.resolve( artifact, repos, getLocalRepository() );
     }
 
     /**
@@ -294,9 +295,7 @@ public class RepositoryUtils
             allowStubModel = true;
         }
 
-        // TODO: we should use the MavenMetadataSource instead
-        return mavenProjectBuilder.buildFromRepository( projectArtifact, remoteRepositories,
localRepository,
-                                                        allowStubModel );
+        return projectBuilder.build( projectArtifact, allowStubModel, buildingRequest ).getProject();
     }
 
     /**
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 327ac79..cc661cc 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
@@ -54,8 +54,9 @@ import org.apache.maven.doxia.util.HtmlTools;
 import org.apache.maven.model.License;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.report.projectinfo.AbstractProjectInfoRenderer;
 import org.apache.maven.report.projectinfo.ProjectInfoReportUtils;
 import org.apache.maven.report.projectinfo.dependencies.Dependencies;
@@ -134,11 +135,9 @@ public class DependenciesRenderer
 
     private final ArtifactFactory artifactFactory;
 
-    private final MavenProjectBuilder mavenProjectBuilder;
+    private final ProjectBuilder projectBuilder;
 
-    private final List<ArtifactRepository> remoteRepositories;
-
-    private final ArtifactRepository localRepository;
+    private final ProjectBuildingRequest buildingRequest;
 
     static
     {
@@ -166,15 +165,14 @@ public class DependenciesRenderer
      * @param config {@link DependenciesReportConfiguration}
      * @param repoUtils {@link RepositoryUtils}
      * @param artifactFactory {@link ArtifactFactory}
-     * @param mavenProjectBuilder {@link MavenProjectBuilder}
-     * @param remoteRepositories {@link ArtifactRepository}
-     * @param localRepository {@link ArtifactRepository}
+     * @param projectBuilder {@link ProjectBuilder}
+     * @param buildingRequest {@link ProjectBuildingRequest}
      */
     public DependenciesRenderer( Sink sink, Locale locale, I18N i18n, Log log, Settings settings,
                                  Dependencies dependencies, DependencyNode dependencyTreeNode,
                                  DependenciesReportConfiguration config, RepositoryUtils
repoUtils,
-                                 ArtifactFactory artifactFactory, MavenProjectBuilder mavenProjectBuilder,
-                                 List<ArtifactRepository> remoteRepositories, ArtifactRepository
localRepository )
+                                 ArtifactFactory artifactFactory, ProjectBuilder projectBuilder,
+                                 ProjectBuildingRequest buildingRequest )
     {
         super( sink, i18n, locale );
 
@@ -185,9 +183,8 @@ public class DependenciesRenderer
         this.repoUtils = repoUtils;
         this.configuration = config;
         this.artifactFactory = artifactFactory;
-        this.mavenProjectBuilder = mavenProjectBuilder;
-        this.remoteRepositories = remoteRepositories;
-        this.localRepository = localRepository;
+        this.projectBuilder = projectBuilder;
+        this.buildingRequest = buildingRequest; 
 
         // Using the right set of symbols depending of the locale
         DEFAULT_DECIMAL_FORMAT.setDecimalFormatSymbols( new DecimalFormatSymbols( locale
) );
@@ -892,8 +889,7 @@ public class DependenciesRenderer
             artifact.isOptional() ? getI18nString( "column.isOptional" ) : getI18nString(
"column.isNotOptional" );
 
         String url =
-            ProjectInfoReportUtils.getArtifactUrl( artifactFactory, artifact, mavenProjectBuilder,
remoteRepositories,
-                                                   localRepository );
+            ProjectInfoReportUtils.getArtifactUrl( artifactFactory, artifact, projectBuilder,
buildingRequest );
         String artifactIdCell = ProjectInfoReportUtils.getArtifactIdCell( artifact.getArtifactId(),
url );
 
         MavenProject artifactProject;
@@ -901,7 +897,7 @@ public class DependenciesRenderer
         try
         {
             artifactProject = repoUtils.getMavenProjectFromRepository( artifact );
-            @SuppressWarnings( "unchecked" )
+
             List<License> licenses = artifactProject.getLicenses();
             for ( License license : licenses )
             {
diff --git a/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependencyManagementRenderer.java
b/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependencyManagementRenderer.java
index efd5fe9..db1b9d3 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependencyManagementRenderer.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependencyManagementRenderer.java
@@ -30,7 +30,6 @@ import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.VersionRange;
@@ -39,8 +38,9 @@ import org.apache.maven.model.Dependency;
 import org.apache.maven.model.License;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.report.projectinfo.AbstractProjectInfoRenderer;
 import org.apache.maven.report.projectinfo.ProjectInfoReportUtils;
 import org.apache.maven.report.projectinfo.dependencies.ManagementDependencies;
@@ -64,11 +64,9 @@ public class DependencyManagementRenderer
 
     private final ArtifactFactory artifactFactory;
 
-    private final MavenProjectBuilder mavenProjectBuilder;
+    private final ProjectBuilder projectBuilder;
 
-    private final List<ArtifactRepository> remoteRepositories;
-
-    private final ArtifactRepository localRepository;
+    private final ProjectBuildingRequest buildingRequest;
 
     private final RepositoryUtils repoUtils;
 
@@ -82,7 +80,7 @@ public class DependencyManagementRenderer
      * @param dependencies {@link ManagementDependencies}
      * @param artifactMetadataSource {@link ArtifactMetadataSource}
      * @param artifactFactory {@link ArtifactFactory}
-     * @param mavenProjectBuilder {@link MavenProjectBuilder}
+     * @param projectBuilder {@link ProjectBuilder}
      * @param remoteRepositories {@link ArtifactRepository}
      * @param localRepository {@link ArtifactRepository}
      * @param repoUtils {@link RepositoryUtils}
@@ -90,9 +88,8 @@ public class DependencyManagementRenderer
     public DependencyManagementRenderer( Sink sink, Locale locale, I18N i18n, Log log,
                                          ManagementDependencies dependencies,
                                          ArtifactMetadataSource artifactMetadataSource,
-                                         ArtifactFactory artifactFactory, MavenProjectBuilder
mavenProjectBuilder,
-                                         List<ArtifactRepository> remoteRepositories,
-                                         ArtifactRepository localRepository, RepositoryUtils
repoUtils )
+                                         ArtifactFactory artifactFactory, ProjectBuilder
projectBuilder,
+                                         ProjectBuildingRequest buildingRequest, RepositoryUtils
repoUtils )
     {
         super( sink, i18n, locale );
 
@@ -100,9 +97,8 @@ public class DependencyManagementRenderer
         this.dependencies = dependencies;
         this.artifactMetadataSource = artifactMetadataSource;
         this.artifactFactory = artifactFactory;
-        this.mavenProjectBuilder = mavenProjectBuilder;
-        this.remoteRepositories = remoteRepositories;
-        this.localRepository = localRepository;
+        this.projectBuilder = projectBuilder;
+        this.buildingRequest = buildingRequest;
         this.repoUtils = repoUtils;
     }
 
@@ -232,7 +228,8 @@ public class DependencyManagementRenderer
                 log.debug( "Resolving range for DependencyManagement on " + artifact.getId()
);
 
                 List<ArtifactVersion> versions =
-                    artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository,
remoteRepositories );
+                    artifactMetadataSource.retrieveAvailableVersions( artifact, buildingRequest.getLocalRepository(),
+                                                                      buildingRequest.getRemoteRepositories()
);
 
                 // only use versions from range
                 for ( Iterator<ArtifactVersion> iter = versions.iterator(); iter.hasNext();
)
@@ -253,9 +250,7 @@ public class DependencyManagementRenderer
                 }
             }
 
-            url =
-                ProjectInfoReportUtils.getArtifactUrl( artifactFactory, artifact, mavenProjectBuilder,
-                                                       remoteRepositories, localRepository
);
+            url = ProjectInfoReportUtils.getArtifactUrl( artifactFactory, artifact, projectBuilder,
buildingRequest );
 
             MavenProject artifactProject = repoUtils.getMavenProjectFromRepository( artifact
);
 

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

Mime
View raw message