maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r940321 - /maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
Date Sun, 02 May 2010 21:36:07 GMT
Author: hboutemy
Date: Sun May  2 21:36:06 2010
New Revision: 940321

URL: http://svn.apache.org/viewvc?rev=940321&view=rev
Log:
code refactoring

Modified:
    maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java

Modified: maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java?rev=940321&r1=940320&r2=940321&view=diff
==============================================================================
--- maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
(original)
+++ maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
Sun May  2 21:36:06 2010
@@ -31,10 +31,11 @@ import org.apache.maven.plugin.AbstractM
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.WriterFactory;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.util.Locale;
 
@@ -58,8 +59,6 @@ public abstract class AbstractMavenRepor
     /** The current report output directory to use */
     private File reportOutputDirectory;
 
-    private Locale locale = Locale.ENGLISH;
-
     /**
      * This method is called when the report is invoked directly as a Mojo, not in the
      * context of a full site generation (where maven-site-plugin:site is the Mojo
@@ -77,48 +76,49 @@ public abstract class AbstractMavenRepor
             return;
         }
 
-        SiteRendererSink sink;
+        Writer writer = null;
         try
         {
-            String outputDirectory = getOutputDirectory();
+            File outputDirectory = new File( getOutputDirectory() );
 
-            sink = new SiteRendererSink( new RenderingContext( new File( outputDirectory
), getOutputName() + ".html" ) );
+            String filename = getOutputName() + ".html";
 
-            generate( sink, null, Locale.getDefault() );
+            Locale locale = Locale.getDefault();
 
-            // TODO: add back when skinning support is in the site renderer
-//            getSiteRenderer().copyResources( outputDirectory, "maven" );
-        }
-        catch ( MavenReportException e )
-        {
-            throw new MojoExecutionException( "An error has occurred in " + getName( locale
) + " report generation.",
-                                              e );
-        }
+            SiteRenderingContext siteContext = new SiteRenderingContext();
+            siteContext.setDecoration( new DecorationModel() );
+            siteContext.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm"
);
+            siteContext.setLocale( locale );
 
-        File outputHtml = new File( getOutputDirectory(), getOutputName() + ".html" );
-        outputHtml.getParentFile().mkdirs();
+            RenderingContext context = new RenderingContext( outputDirectory, filename );
 
-        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 );
+            SiteRendererSink sink = new SiteRendererSink( context );
+
+            generate( sink, null, locale );
+
+            outputDirectory.mkdirs();
+
+            writer = new OutputStreamWriter( new FileOutputStream( new File( outputDirectory,
filename ) ), "UTF-8" );
 
-            writer = WriterFactory.newXmlWriter( outputHtml );
+            getSiteRenderer().generateDocument( writer, sink, siteContext );
 
-            getSiteRenderer().generateDocument( writer, sink, context );
+            //getSiteRenderer().copyResources( siteContext, new File( project.getBasedir(),
"src/site/resources" ),
+            //                            outputDirectory );
         }
         catch ( RendererException e )
         {
-            throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH
)
-                + " report generation.", 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 );
+            throw new MojoExecutionException(
+                "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation.",
e );
+        }
+        catch ( MavenReportException e )
+        {
+            throw new MojoExecutionException(
+                "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation.",
e );
         }
         finally
         {



Mime
View raw message