You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2011/11/22 12:37:35 UTC

svn commit: r1204931 - /maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java

Author: stephenc
Date: Tue Nov 22 11:37:34 2011
New Revision: 1204931

URL: http://svn.apache.org/viewvc?rev=1204931&view=rev
Log:
[SUREFIRE-772] Skip Maven Failsafe Report

o And this is why we write tests... velocity will still generate the report file unless we tell it the report cannot be generated.

o Todo: The tests are not ready to commit yet, but in progress

Modified:
    maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java

Modified: maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java?rev=1204931&r1=1204930&r2=1204931&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/AbstractSurefireReportMojo.java Tue Nov 22 11:37:34 2011
@@ -139,9 +139,67 @@ public abstract class AbstractSurefireRe
     {
         if ( isSkipped() )
         {
-            getLog().info( getOutputName() + " generation skipped." );
             return;
         }
+
+        final List reportsDirectoryList = getReportsDirectories();
+
+        if ( reportsDirectoryList == null )
+        {
+            return;
+        }
+
+        if ( isGeneratedWhenNoResults() )
+        {
+            boolean atLeastOneDirectoryExists = false;
+            for ( Iterator i = reportsDirectoryList.iterator(); i.hasNext() && !atLeastOneDirectoryExists; )
+            {
+                atLeastOneDirectoryExists = SurefireReportParser.hasReportFiles( (File) i.next() );
+            }
+            if ( !atLeastOneDirectoryExists )
+            {
+                return;
+            }
+        }
+
+        SurefireReportGenerator report =
+            new SurefireReportGenerator( reportsDirectoryList, locale, showSuccess, determineXrefLocation() );
+
+        report.doGenerateReport( getBundle( locale ), getSink() );
+    }
+
+    public boolean canGenerateReport()
+    {
+        if ( isSkipped() )
+        {
+            return false;
+        }
+
+        final List reportsDirectoryList = getReportsDirectories();
+
+        if ( reportsDirectoryList == null )
+        {
+            return false;
+        }
+
+        if ( isGeneratedWhenNoResults() )
+        {
+            boolean atLeastOneDirectoryExists = false;
+            for ( Iterator i = reportsDirectoryList.iterator(); i.hasNext() && !atLeastOneDirectoryExists; )
+            {
+                atLeastOneDirectoryExists = SurefireReportParser.hasReportFiles( (File) i.next() );
+            }
+            if ( !atLeastOneDirectoryExists )
+            {
+                return false;
+            }
+        }
+
+        return super.canGenerateReport();
+    }
+
+    private List getReportsDirectories()
+    {
         final List reportsDirectoryList = new ArrayList();
 
         if ( reportsDirectories != null )
@@ -158,7 +216,7 @@ public abstract class AbstractSurefireRe
         {
             if ( !project.isExecutionRoot() )
             {
-                return;
+                return null;
             }
             if ( reportsDirectories == null )
             {
@@ -201,24 +259,7 @@ public abstract class AbstractSurefireRe
                 reportsDirectoryList.add( getSurefireReportsDirectory( project ) );
             }
         }
-
-        if ( isGeneratedWhenNoResults() )
-        {
-            boolean atLeastOneDirectoryExists = false;
-            for ( Iterator i = reportsDirectoryList.iterator(); i.hasNext() && !atLeastOneDirectoryExists; )
-            {
-                atLeastOneDirectoryExists = SurefireReportParser.hasReportFiles( (File) i.next() );
-            }
-            if ( !atLeastOneDirectoryExists )
-            {
-                getLog().info( getOutputName() + " generation skipped as there are no report files to report." );
-            }
-        }
-
-        SurefireReportGenerator report =
-            new SurefireReportGenerator( reportsDirectoryList, locale, showSuccess, determineXrefLocation() );
-
-        report.doGenerateReport( getBundle( locale ), getSink() );
+        return reportsDirectoryList;
     }
 
     /**