org.apache.maven.reporting
Class AbstractMavenReport

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.apache.maven.reporting.AbstractMavenReport
All Implemented Interfaces:
ContextEnabled, Mojo, MavenMultiPageReport, MavenReport

public abstract class AbstractMavenReport
extends AbstractMojo
implements MavenMultiPageReport

The basis for a Maven report which can be generated both as part of a site generation or as a direct standalone invocation. Both invocations are delegated to abstract executeReport( Locale ):

Since:
2.0
Version:
$Id: AbstractMavenReport.java 1164275 2011-09-01 21:11:46Z hboutemy $
Author:
Emmanuel Venisse
See Also:
Mojo.execute() (from maven-plugin-api), MavenMultiPageReport.generate( Sink, SinkFactory, Locale ) (from maven-reporting-api), abstract executeReport( Locale )

Field Summary
 
Fields inherited from interface org.apache.maven.reporting.MavenReport
CATEGORY_PROJECT_INFORMATION, CATEGORY_PROJECT_REPORTS, ROLE
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractMavenReport()
           
 
Method Summary
 boolean canGenerateReport()
          
protected  void closeReport()
          Actions when closing the report.
 void execute()
          This method is called when the report generation is invoked directly as a standalone Mojo.
protected abstract  void executeReport(Locale locale)
          Execute the generation of the report.
 void generate(Sink aSink, Locale aLocale)
          Deprecated. use generate(Sink, SinkFactory, Locale) instead.
 void generate(Sink aSink, Locale aLocale)
          Deprecated. use generate(Sink, SinkFactory, Locale) instead.
 void generate(Sink aSink, SinkFactory aSinkFactory, Locale aLocale)
          This method is called when the report generation is invoked by maven-site-plugin.
 String getCategoryName()
          
protected abstract  String getOutputDirectory()
          The output directory when the mojo is run directly from the command line.
protected abstract  MavenProject getProject()
           
 File getReportOutputDirectory()
          
 Sink getSink()
           
 SinkFactory getSinkFactory()
           
protected abstract  Renderer getSiteRenderer()
           
 boolean isExternalReport()
           
 void setReportOutputDirectory(File reportOutputDirectory)
          
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.maven.reporting.MavenReport
getDescription, getName, getOutputName
 

Constructor Detail

AbstractMavenReport

public AbstractMavenReport()
Method Detail

execute

public void execute()
             throws MojoExecutionException
This method is called when the report generation is invoked directly as a standalone Mojo.

Specified by:
execute in interface Mojo
Throws:
MojoExecutionException - if an error occurs when generating the report
See Also:
org.apache.maven.plugins.site.ReportDocumentRender, Mojo.execute()

generate

public void generate(Sink aSink,
                     Locale aLocale)
              throws MavenReportException
Deprecated. use generate(Sink, SinkFactory, Locale) instead.

Generate a report.

Specified by:
generate in interface MavenReport
Parameters:
aSink - the sink to use for the generation.
aLocale - the wanted locale to generate the report, could be null.
Throws:
MavenReportException - if any

generate

public void generate(Sink aSink,
                     Locale aLocale)
              throws MavenReportException
Deprecated. use generate(Sink, SinkFactory, Locale) instead.

Generate a report.

Parameters:
aSink -
aLocale -
Throws:
MavenReportException
See Also:
org.apache.maven.reporting.MavenReport#generate(org.apache.maven.doxia.sink.Sink, java.util.Locale)

generate

public void generate(Sink aSink,
                     SinkFactory aSinkFactory,
                     Locale aLocale)
              throws MavenReportException
This method is called when the report generation is invoked by maven-site-plugin.

Specified by:
generate in interface MavenMultiPageReport
Parameters:
aSink -
aSinkFactory -
aLocale -
Throws:
MavenReportException

getCategoryName

public String getCategoryName()

Specified by:
getCategoryName in interface MavenReport
Returns:
CATEGORY_PROJECT_REPORTS

getReportOutputDirectory

public File getReportOutputDirectory()

Specified by:
getReportOutputDirectory in interface MavenReport

setReportOutputDirectory

public void setReportOutputDirectory(File reportOutputDirectory)

Specified by:
setReportOutputDirectory in interface MavenReport

closeReport

protected void closeReport()
Actions when closing the report.


getSink

public Sink getSink()
Returns:
the sink used

getSinkFactory

public SinkFactory getSinkFactory()
Returns:
the sink factory used

isExternalReport

public boolean isExternalReport()
Specified by:
isExternalReport in interface MavenReport
Returns:
false by default.
See Also:
MavenReport.isExternalReport()

canGenerateReport

public boolean canGenerateReport()

Specified by:
canGenerateReport in interface MavenReport

getSiteRenderer

protected abstract Renderer getSiteRenderer()
Returns:
the site renderer used.

getOutputDirectory

protected abstract String getOutputDirectory()
The output directory when the mojo is run directly from the command line. Implementors should use this method to return the value of a mojo parameter that the user may use to customize the output directory.
Note: When the mojo is run as part of a site generation, Maven will set the effective output directory via MavenReport.setReportOutputDirectory(java.io.File). In this case, the return value of this method is irrelevant. Therefore, developers should always call getReportOutputDirectory() to get the effective output directory for the report. The later method will eventually fallback to this method if the mojo is not run as part of a site generation.

Returns:
The path to the output directory as specified in the plugin configuration for this report.

getProject

protected abstract MavenProject getProject()
Returns:
the Maven project instance.

executeReport

protected abstract void executeReport(Locale locale)
                               throws MavenReportException
Execute the generation of the report.

Parameters:
locale - the wanted locale to return the report's description, could be null.
Throws:
MavenReportException - if any


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.