[ 
http://jira.codehaus.org/browse/SUREFIRE-357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_109802
 ] 

David Cardon edited comment on SUREFIRE-357 at 10/12/07 2:40 PM:
-----------------------------------------------------------------

Here is a patch I created:

{code}
Index: 
src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
===================================================================
--- 
src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java  
    (revision 584226)
+++ 
src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java  
    (working copy)
@@ -25,11 +25,14 @@
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
 import org.codehaus.doxia.site.renderer.SiteRenderer;
+import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.PathTool;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
@@ -195,8 +198,19 @@
      */
     public boolean canGenerateReport()
     {
-        // Only execute reports for java projects
-        ArtifactHandler artifactHandler = 
this.project.getArtifact().getArtifactHandler();
-        return "java".equals( artifactHandler.getLanguage() );
+       try
+       {
+               if ( reportsDirectory.exists() && 
reportsDirectory.isDirectory() )
+               {
+                       List fileList = FileUtils.getFileNames( 
reportsDirectory, "**/TEST-*.xml", "", true );
+                       return !fileList.isEmpty();
+               }
+       }
+       catch ( IOException e )
+       {
+               getLog().error( "Error accessing reports directory!" );
+       }
+       
+       return false;
     }
 }
{code}


 was:
Here is a patch I created:

Index: 
src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
===================================================================
--- 
src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java  
    (revision 584226)
+++ 
src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java  
    (working copy)
@@ -25,11 +25,14 @@
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
 import org.codehaus.doxia.site.renderer.SiteRenderer;
+import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.PathTool;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
@@ -195,8 +198,19 @@
      */
     public boolean canGenerateReport()
     {
-        // Only execute reports for java projects
-        ArtifactHandler artifactHandler = 
this.project.getArtifact().getArtifactHandler();
-        return "java".equals( artifactHandler.getLanguage() );
+       try
+       {
+               if ( reportsDirectory.exists() && 
reportsDirectory.isDirectory() )
+               {
+                       List fileList = FileUtils.getFileNames( 
reportsDirectory, "**/TEST-*.xml", "", true );
+                       return !fileList.isEmpty();
+               }
+       }
+       catch ( IOException e )
+       {
+               getLog().error( "Error accessing reports directory!" );
+       }
+       
+       return false;
     }
 }


> Java language constraint is a poor criteria for surefire report generation
> --------------------------------------------------------------------------
>
>                 Key: SUREFIRE-357
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-357
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: report plugin
>    Affects Versions: 2.3
>            Reporter: David Cardon
>
> With the expansion of maven as a project management tool for other (non-Java) 
> languages, the 'canGenerateReport' function in SurefireReportMojo.java limits 
> the scope of the report plugin to only Java projects.  This limitation 
> prevents the use of surefire xml as a standard format for test reports.  
> Perhaps a more relevant approach to the function would be to test for the 
> existence of the 'surefire-reports' folder and relevant files within that 
> folder.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to