Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

== AbstractMavenReport ==

You need to implement your Mojo as AbstractMavenReport, then you can simply add it to the <plugin> section within the <reporting><plugins> section of your POM and your report will be generated and linked into the Maven site automagically: {{

  • @author me
  • @goal my-report
  • @phase site
    public class MyReportMojo extends AbstractMavenReport {
    /**
  • Directory where reports will go.
    *
  • @parameter expression="$
    Unknown macro: {project.reporting.outputDirectory}
    "
  • @required
  • @readonly
    */
    private String outputDirectory;
    }} and so on. `@phase site` binds your plugin to the site lifecycle of the build.

You need to implement or override the following methods:

  • `public void executeReport(Locale defaultLocale) throws MavenReportException`
  • This method is called during site phase to actually produce your report.
  • {{
    protected MavenProject getProject()
    Unknown macro: { return project; }

protected String getOutputDirectory()

Unknown macro: { return outputDirectory; }

protected Renderer getSiteRenderer()

Unknown macro: { return siteRenderer; }
  • - - -
    public String getDescription( Locale locale )
    Unknown macro: { return getBundle( locale ).getString( "report.myreport.description" ); }
  • - - -
    public String getName( Locale locale )
    Unknown macro: { return getBundle( locale ).getString( "report.myreport.name" ); }

public String getOutputName()

Unknown macro: { return "my-report"; }

private ResourceBundle getBundle( Locale locale )

Unknown macro: { return ResourceBundle.getBundle( "my-report", locale, this.getClass().getClassLoader() ); }

}} For the use of getBundle() you need to provide a resource bundle in `src/main/resources/my-report.properties` that contains the necessary keys for your plugin, e.g. {{{
report.dashboard.name=Dashboard Report
report.dashboard.description=Dashboard Report on Releases of the Project.
report.dashboard.header=Dashboard Report
report.dashboard.label.releasehistory=Release History
report.dashboard.label.release=Release
report.dashboard.label.version=Version
report.dashboard.label.date=Date
report.dashboard.label.type=Type
report.dashboard.label.dashboard=Dashboard
report.dashboard.label.description=Description
report.dashboard.label.by=By
report.dashboard.text.rssfeed=Get the RSS feed of the last dashboard
report.dashboard.text.thanx=Thanks to
report.dashboard.text.fixes=Fixes
report.dashboard.error=Cannot find the Dashboard XML file.
report.dashboard.warn.url=No Issue Management/URL defined in pom.xml. Links to your issues will not work correctly.
}}}

Note:: If you want to create the report without using Doxia, e.g. via XSL transformation from some XML file, then simply add the following method to your Mojo: {{
public boolean isExternalReport()

Unknown macro: { return true; }

}}

== Doxia ==
You also need to use the Doxia Sink API to have complete decoration (ie. menus). That is quite straightforward. You simply import `org.apache.maven.doxia.sink.Sink` and get an instance by simply calling the class method `getSink()` (you don't even have to implement it). Then you can do things like that:{{

Unknown macro: {sink.tableCell(); sink.text( "some text" ); sink.tableCell_();}}

to get {{

Unknown macro: { <td>some text</td>}}

.

  • No labels