maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r806843 - /maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
Date Sat, 22 Aug 2009 11:55:53 GMT
Author: bentmann
Date: Sat Aug 22 11:55:53 2009
New Revision: 806843

URL: http://svn.apache.org/viewvc?rev=806843&view=rev
Log:
o Added workaround for MSHARED-120 as suggested by Vincent's patch for the issue

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

Modified: maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java?rev=806843&r1=806842&r2=806843&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
(original)
+++ maven/surefire/trunk/maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/SurefireReportMojo.java
Sat Aug 22 11:55:53 2009
@@ -20,19 +20,29 @@
  */
 
 import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
+import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.doxia.siterenderer.RendererException;
+import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
+import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
 import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
+import org.apache.maven.reporting.sink.SinkFactory;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.PathTool;
 import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.WriterFactory;
 
 
 /**
@@ -129,6 +139,63 @@
      */
     private boolean aggregate;
 
+    // TODO: Remove this override once MSHARED-120 is released
+    public void execute()
+        throws MojoExecutionException
+    {
+        Locale locale = Locale.getDefault();
+
+        SiteRendererSink sink;
+        try
+        {
+            sink = SinkFactory.createSink( new File( getOutputDirectory() ), getOutputName()
+ ".html" );
+
+            try
+            {
+                generate( sink, locale );
+            }
+            finally
+            {
+                sink.close();
+            }
+        }
+        catch ( MavenReportException e )
+        {
+            throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH
)
+                + " report generation.", e );
+        }
+
+        File outputHtml = new File( getOutputDirectory(), getOutputName() + ".html" );
+        outputHtml.getParentFile().mkdirs();
+
+        Writer writer = null;
+        try
+        {
+            SiteRenderingContext context = new SiteRenderingContext();
+            context.setDecoration( new DecorationModel() );
+            context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm"
);
+            context.setLocale( locale );
+
+            writer = WriterFactory.newXmlWriter( outputHtml );
+
+            getSiteRenderer().generateDocument( writer, sink, context );
+        }
+        catch ( RendererException e )
+        {
+            throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH
)
+                + " report generation.", e );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH
)
+                + " report generation.", e );
+        }
+        finally
+        {
+            IOUtil.close( writer );
+        }
+    }
+
     /** {@inheritDoc} */
     public void executeReport( Locale locale )
         throws MavenReportException



Mime
View raw message