Hi again,

4) Effective Output Directory for Report Plugins

Most reporting plugins will inherit from AbstractMavenReport. In doing so,
they need to implement the inherited but abstract method
getOutputDirectory(). To implement this method, plugins usually declare a
field named "outputDirectory" which they return in the method. Nothing wrong
so far, but please read on.

Some plugins need to create additional files in the report output directory
that accompany the report generated via the sink. While it is tempting to
use either the method getOutputDirectory() or the field outputDirectory
directly in order to setup a path for the output files, this leads most
likely to a bug. More precisely, those plugins will not properly output
files when run by the Maven Site Plugin as part of the site lifecycle. This
is best noticed when the output directory for the site is configured
directly in the Maven Site Plugin such that it deviates from the expression
${project.reporting.outputDirectory} that the plugins use. Multi-language
site generation is another scenario to exploit the bug.

The reason for this: During the site lifecycle, the Maven Site Plugin takes
control of the output directory, that's why all reports (ideally) end up in
the same directory. In order to do, it invokes
MavenReport.setReportOutputDirectory() on each report. Reports are expected
to use the supplied path and not a value from the POM configuration of the
corresponding reporting plugin.

As the take home message: If one needs to know the effective output
directory for the report, MavenReport.getReportOutputDirectory() is your
friend.

And what about AbstractMavenReport.getOutputDirectory()? Well, the
implementation of getReportOutputDirectory() in AbstractMavenReport will
fallback to this method if the Maven Site Plugin did not previously set the
output directory (see also [0]).

Regards,


Benjamin Bentmann


[0] http://jira.codehaus.org/browse/MNG-3369


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to