maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1598682 - /maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java
Date Fri, 30 May 2014 17:45:28 GMT
Author: hboutemy
Date: Fri May 30 17:45:28 2014
New Revision: 1598682

URL: http://svn.apache.org/r1598682
Log:
refactored

Modified:
    maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java

Modified: maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java?rev=1598682&r1=1598681&r2=1598682&view=diff
==============================================================================
--- maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java
(original)
+++ maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractSiteRenderingMojo.java
Fri May 30 17:45:28 2014
@@ -214,8 +214,11 @@ public abstract class AbstractSiteRender
     protected List<MavenReportExecution> getReports()
         throws MojoExecutionException
     {
+        List<MavenReportExecution> allReports;
+
         if ( isMaven3OrMore() )
         {
+            // Maven 3
             MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
             mavenReportExecutorRequest.setLocalRepository( localRepository );
             mavenReportExecutorRequest.setMavenSession( mavenSession );
@@ -232,46 +235,29 @@ public abstract class AbstractSiteRender
                 throw new MojoExecutionException( "could not get MavenReportExecutor component",
e );
             }
 
-            List<MavenReportExecution> allReports = mavenReportExecutor.buildMavenReports(
mavenReportExecutorRequest );
-
-            // filter out reports that can't be generated
-            List<MavenReportExecution> reportExecutions = new ArrayList<MavenReportExecution>(
allReports.size() );
-            for ( MavenReportExecution exec : allReports )
+            allReports = mavenReportExecutor.buildMavenReports( mavenReportExecutorRequest
);
+        }
+        else
+        {
+            // Maven 2
+            allReports = new ArrayList<MavenReportExecution>( reports.size() );
+            for ( MavenReport report : reports )
             {
-                if ( canGenerateReport( exec ) )
-                {
-                    reportExecutions.add( exec );
-                }
+                allReports.add( new MavenReportExecution( report ) );
             }
-
-            return reportExecutions;
         }
 
-        // Maven 2
-        List<MavenReportExecution> reportExecutions = new ArrayList<MavenReportExecution>(
reports.size() );
-        for ( MavenReport report : reports )
+        // filter out reports that can't be generated
+        List<MavenReportExecution> reportExecutions = new ArrayList<MavenReportExecution>(
allReports.size() );
+        for ( MavenReportExecution exec : allReports )
         {
-            if ( report.canGenerateReport() )
+            if ( exec.canGenerateReport() )
             {
-                reportExecutions.add( new MavenReportExecution( report ) );
+                reportExecutions.add( exec );
             }
         }
-        return reportExecutions;
-    }
 
-    private boolean canGenerateReport( MavenReportExecution exec )
-    {
-        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
-        try
-        {
-            Thread.currentThread().setContextClassLoader( exec.getClassLoader() );
-
-            return exec.getMavenReport().canGenerateReport();
-        }
-        finally
-        {
-            Thread.currentThread().setContextClassLoader( originalClassLoader );
-        } 
+        return reportExecutions;
     }
 
     protected SiteRenderingContext createSiteRenderingContext( Locale locale )



Mime
View raw message