Author: svn-site-role Date: Thu Dec 4 19:20:20 2025 New Revision: 1930256 Log: Site checkin for project Apache Maven Site
Modified: maven/website/content/plugin-developers/common-bugs.html Modified: maven/website/content/plugin-developers/common-bugs.html ============================================================================== --- maven/website/content/plugin-developers/common-bugs.html Thu Dec 4 18:45:02 2025 (r1930255) +++ maven/website/content/plugin-developers/common-bugs.html Thu Dec 4 19:20:20 2025 (r1930256) @@ -275,7 +275,7 @@ if ( "info".equals( debugLevel <h2>Using System Properties</h2> <p>Maven's command line supports the definition of system properties via arguments of the form <code>-D key=value</code>. While these properties are called system properties, plugins should never use <a href="http://java.sun.com/javase/6/docs/api/java/lang/System.html#getProperty(java.lang.String)" class="externalLink"><code>System.getProperty()</code></a> and related methods to query these properties. For example, the following code snippet will not work reliably when Maven is embedded, say into an IDE or a CI server:</p> -<pre class="prettyprint linenums"><code class="language-unknown">public MyMojo extends AbstractMojo +<pre class="prettyprint linenums"><code class="language-unknown">public class MyMojo extends AbstractMojo { public void execute() { @@ -290,7 +290,7 @@ if ( "info".equals( debugLevel <h2>Using Shutdown Hooks</h2> <p>People occasionally employ shutdown hooks to perform cleanup tasks, e.g. to delete temporary files as shown in the example below:</p> -<pre class="prettyprint linenums"><code class="language-unknown">public MyMojo extends AbstractMojo +<pre class="prettyprint linenums"><code class="language-unknown">public class MyMojo extends AbstractMojo { public void execute() { @@ -323,7 +323,7 @@ if ( "info".equals( debugLevel </ol> <p>Hence this example code is prone to misbehave:</p> -<pre class="prettyprint linenums"><code class="language-unknown">public MyMojo extends AbstractMojo +<pre class="prettyprint linenums"><code class="language-unknown">public class MyMojo extends AbstractMojo { /** * @parameter @@ -353,7 +353,7 @@ if ( !file.isAbsolute() ) <p>Most reporting plugins inherit from <code>AbstractMavenReport</code>. In doing so, they need to implement the inherited but abstract method <code>getOutputDirectory()</code>. To implement this method, plugins usually declare a field named <code>outputDirectory</code> which they return in the method. Nothing wrong so far.</p> <p>Now, some plugins need to create additional files in the report output directory that accompany the report generated via the sink interface. While it is tempting to use either the method <code>getOutputDirectory()</code> or the field <code>outputDirectory</code> 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 <code>${project.reporting.outputDirectory}</code> that the plugins use by default. Multi-language site generation is another scenario to exploit this bug which is illustrated below:</p> -<pre class="prettyprint linenums"><code class="language-unknown">public MyReportMojo extends AbstractMavenReport +<pre class="prettyprint linenums"><code class="language-unknown">public class MyReportMojo extends AbstractMavenReport { /** * @parameter default-value="${project.reporting.outputDirectory}"
