You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2010/05/08 23:58:02 UTC
svn commit: r942472 -
/maven/shared/branches/maven-reporting-impl-2.0.4.x/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
Author: hboutemy
Date: Sat May 8 21:58:02 2010
New Revision: 942472
URL: http://svn.apache.org/viewvc?rev=942472&view=rev
Log:
merged code reformatting from trunk
Modified:
maven/shared/branches/maven-reporting-impl-2.0.4.x/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
Modified: maven/shared/branches/maven-reporting-impl-2.0.4.x/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
URL: http://svn.apache.org/viewvc/maven/shared/branches/maven-reporting-impl-2.0.4.x/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java?rev=942472&r1=942471&r2=942472&view=diff
==============================================================================
--- maven/shared/branches/maven-reporting-impl-2.0.4.x/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java (original)
+++ maven/shared/branches/maven-reporting-impl-2.0.4.x/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java Sat May 8 21:58:02 2010
@@ -47,6 +47,7 @@ public abstract class AbstractMavenRepor
extends AbstractMojo
implements MavenReport
{
+ /** The current sink to use */
private Sink sink;
private Locale locale = Locale.ENGLISH;
@@ -57,48 +58,52 @@ public abstract class AbstractMavenRepor
protected abstract MavenProject getProject();
+ /** The current report output directory to use */
private File reportOutputDirectory;
/**
+ * 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
+ * being executed)
+ *
+ * @throws MojoExecutionException always
+ * @see org.apache.maven.plugins.site.ReportDocumentRender
* @see org.apache.maven.plugin.Mojo#execute()
*/
public void execute()
throws MojoExecutionException
{
- SiteRendererSink sink;
+ Writer writer = null;
try
{
- String outputDirectory = getOutputDirectory();
+ File outputDirectory = new File( getOutputDirectory() );
+
+ String filename = getOutputName() + ".html";
+
+ SiteRenderingContext context = new SiteRenderingContext();
+ context.setDecoration( new DecorationModel() );
+ context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
+ context.setLocale( locale );
- sink =
- SinkFactory.createSink( new File( outputDirectory ), getOutputName() + ".html" );
+ SiteRendererSink sink = SinkFactory.createSink( outputDirectory, filename );
generate( sink, 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 );
- }
-
- 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 );
+ File outputHtml = new File( outputDirectory, filename );
+ outputHtml.getParentFile().mkdirs();
writer = WriterFactory.newXmlWriter( outputHtml );
getSiteRenderer().generateDocument( writer, sink, context );
}
+ catch ( MavenReportException e )
+ {
+ throw new MojoExecutionException( "An error has occurred in " + getName( locale ) + " report generation.",
+ e );
+ }
catch ( RendererException e )
{
throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
@@ -141,11 +146,13 @@ public abstract class AbstractMavenRepor
getSink().close();
}
+ /** {@inheritDoc} */
public String getCategoryName()
{
return CATEGORY_PROJECT_REPORTS;
}
+ /** {@inheritDoc} */
public File getReportOutputDirectory()
{
if ( reportOutputDirectory == null )
@@ -155,21 +162,30 @@ public abstract class AbstractMavenRepor
return reportOutputDirectory;
}
+ /** {@inheritDoc} */
public void setReportOutputDirectory( File reportOutputDirectory )
{
this.reportOutputDirectory = reportOutputDirectory;
}
+ /**
+ * @return the sink used
+ */
public Sink getSink()
{
return sink;
}
+ /**
+ * @see org.apache.maven.reporting.MavenReport#isExternalReport()
+ * @return <tt>false</tt> by default.
+ */
public boolean isExternalReport()
{
return false;
}
+ /** {@inheritDoc} */
public boolean canGenerateReport()
{
return true;