Author: hboutemy
Date: Sat Sep 13 23:35:26 2014
New Revision: 1624792

URL: http://svn.apache.org/r1624792
Log:
[MSHARED-347] use plugin-tools java 5 annotations to avoid copy/paste when 
implementing

Modified:
    maven/shared/trunk/maven-reporting-impl/pom.xml
    
maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
    
maven/shared/trunk/maven-reporting-impl/src/test/java/org/apache/maven/reporting/AbstractMavenReportTest.java

Modified: maven/shared/trunk/maven-reporting-impl/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-impl/pom.xml?rev=1624792&r1=1624791&r2=1624792&view=diff
==============================================================================
--- maven/shared/trunk/maven-reporting-impl/pom.xml (original)
+++ maven/shared/trunk/maven-reporting-impl/pom.xml Sat Sep 13 23:35:26 2014
@@ -74,7 +74,7 @@
       <version>3.0</version>
     </dependency>
 
-    <!-- maven -->
+    <!-- Maven -->
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
@@ -88,10 +88,10 @@
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-shared-utils</artifactId>
-      <version>0.3</version>
+      <version>0.6</version>
     </dependency>
 
-    <!-- doxia -->
+    <!-- Doxia -->
     <dependency>
       <groupId>org.apache.maven.doxia</groupId>
       <artifactId>doxia-sink-api</artifactId>
@@ -110,6 +110,11 @@
 
     <!-- misc -->
     <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>commons-validator</groupId>
       <artifactId>commons-validator</artifactId>
       <version>1.3.1</version>

Modified: 
maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java?rev=1624792&r1=1624791&r2=1624792&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
 (original)
+++ 
maven/shared/trunk/maven-reporting-impl/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
 Sat Sep 13 23:35:26 2014
@@ -29,6 +29,8 @@ import org.apache.maven.doxia.siterender
 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.utils.io.IOUtil;
 
@@ -62,6 +64,26 @@ public abstract class AbstractMavenRepor
     extends AbstractMojo
     implements MavenMultiPageReport
 {
+    /**
+     * The output directory for the report. Note that this parameter is only 
evaluated if the goal is run directly from
+     * the command line. If the goal is run indirectly as part of a site 
generation, the output directory configured in
+     * the Maven Site Plugin is used instead.
+     */
+    @Parameter( defaultValue = "${project.reporting.outputDirectory}", 
readonly = true, required = true )
+    protected File outputDirectory;
+
+    /**
+     * The Maven Project.
+     */
+    @Parameter( defaultValue = "${project}", readonly = true, required = true )
+    protected MavenProject project;
+
+    /**
+     * Doxia Site Renderer component.
+     */
+    @Component
+    protected Renderer siteRenderer;
+
     /** The current sink to use */
     private Sink sink;
 
@@ -71,6 +93,21 @@ public abstract class AbstractMavenRepor
     /** The current report output directory to use */
     private File reportOutputDirectory;
 
+    protected String getOutputDirectory()
+    {
+        return outputDirectory.getAbsolutePath();
+    }
+
+    protected MavenProject getProject()
+    {
+        return project;
+    }
+
+    protected Renderer getSiteRenderer()
+    {
+        return siteRenderer;
+    }
+
     /**
      * This method is called when the report generation is invoked directly as 
a standalone Mojo.
      *
@@ -245,6 +282,7 @@ public abstract class AbstractMavenRepor
     public void setReportOutputDirectory( File reportOutputDirectory )
     {
         this.reportOutputDirectory = reportOutputDirectory;
+        this.outputDirectory = reportOutputDirectory;
     }
 
     /**
@@ -287,31 +325,6 @@ public abstract class AbstractMavenRepor
     }
 
     /**
-     * @return the site renderer used.
-     */
-    protected abstract Renderer getSiteRenderer();
-
-    /**
-     * 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.
-     * <br/>
-     * <strong>Note:</strong>
-     * When the mojo is run as part of a site generation, Maven will set the 
effective output directory via
-     * {@link 
org.apache.maven.reporting.MavenReport#setReportOutputDirectory(java.io.File)}. 
In this case, the return
-     * value of this method is irrelevant. Therefore, developers should always 
call {@link #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.
-     *
-     * @return The path to the output directory as specified in the plugin 
configuration for this report.
-     */
-    protected abstract String getOutputDirectory();
-
-    /**
-     * @return the Maven project instance.
-     */
-    protected abstract MavenProject getProject();
-
-    /**
      * Execute the generation of the report.
      *
      * @param locale the wanted locale to return the report's description, 
could be <code>null</code>.

Modified: 
maven/shared/trunk/maven-reporting-impl/src/test/java/org/apache/maven/reporting/AbstractMavenReportTest.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-reporting-impl/src/test/java/org/apache/maven/reporting/AbstractMavenReportTest.java?rev=1624792&r1=1624791&r2=1624792&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-reporting-impl/src/test/java/org/apache/maven/reporting/AbstractMavenReportTest.java
 (original)
+++ 
maven/shared/trunk/maven-reporting-impl/src/test/java/org/apache/maven/reporting/AbstractMavenReportTest.java
 Sat Sep 13 23:35:26 2014
@@ -19,65 +19,18 @@ package org.apache.maven.reporting;
  * under the License.
  */
 
-import java.io.File;
 import java.util.Locale;
 
-import org.apache.maven.doxia.siterenderer.Renderer;
-import org.apache.maven.project.MavenProject;
+import org.apache.maven.plugins.annotations.Mojo;
 
 /**
  * Typical code to copy as a reporting plugin start: choose the goal name, 
then implement getOutputName(),
  * getName( Locale ), getDescription( Locale ) and of course executeReport( 
Locale ).
- * 
- * @goal test
  */
+@Mojo( name = "test" )
 public class AbstractMavenReportTest
     extends AbstractMavenReport
 {
-    /**
-     * The output directory for the report. Note that this parameter is only 
evaluated if the goal is run directly from
-     * the command line. If the goal is run indirectly as part of a site 
generation, the output directory configured in
-     * the Maven Site Plugin is used instead.
-     *
-     * @parameter default-value="${project.reporting.outputDirectory}"
-     * @required
-     */
-    protected File outputDirectory;
-
-    /**
-     * The Maven Project.
-     *
-     * @parameter default-value="${project}"
-     * @required
-     * @readonly
-     */
-    protected MavenProject project;
-
-    /**
-     * Doxia Site Renderer component.
-     *
-     * @component
-     */
-    protected Renderer siteRenderer;
-
-    @Override
-    protected String getOutputDirectory()
-    {
-        return outputDirectory.getAbsolutePath();
-    }
-
-    @Override
-    protected MavenProject getProject()
-    {
-        return project;
-    }
-
-    @Override
-    protected Renderer getSiteRenderer()
-    {
-        return siteRenderer;
-    }
-
     public String getOutputName()
     {
         return "abstract-maven-report-test";


Reply via email to