You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/03/08 10:49:14 UTC

[maven-reporting-impl] branch mvn4 updated: runtime support

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch mvn4
in repository https://gitbox.apache.org/repos/asf/maven-reporting-impl.git


The following commit(s) were added to refs/heads/mvn4 by this push:
     new bc80ac9  runtime support
bc80ac9 is described below

commit bc80ac97a1f917031276b77f8ba9660c2e011ecb
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Mar 8 11:49:12 2022 +0100

    runtime support
---
 pom.xml                                            | 13 ++-------
 .../maven/reporting/AbstractMavenReport.java       | 32 ++++++++++++----------
 2 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/pom.xml b/pom.xml
index 6fb04cd..6908b81 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,13 +85,9 @@
     <!-- Maven -->
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-core</artifactId>
-      <version>${mavenVersion}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
+      <artifactId>maven-core-api</artifactId>
       <version>${mavenVersion}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
@@ -128,11 +124,6 @@
 
     <!-- misc -->
     <dependency>
-      <groupId>org.apache.maven.plugin-tools</groupId>
-      <artifactId>maven-plugin-annotations</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
       <version>3.0.24</version>
diff --git a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
index 8eb7c4f..da4df9e 100644
--- a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
+++ b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
@@ -19,6 +19,10 @@ package org.apache.maven.reporting;
  * under the License.
  */
 
+import org.apache.maven.api.Project;
+import org.apache.maven.api.plugin.MojoException;
+import org.apache.maven.api.plugin.annotations.Component;
+import org.apache.maven.api.plugin.annotations.Parameter;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkFactory;
 import org.apache.maven.doxia.site.decoration.DecorationModel;
@@ -27,13 +31,10 @@ import org.apache.maven.doxia.siterenderer.RendererException;
 import org.apache.maven.doxia.siterenderer.RenderingContext;
 import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
 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.WriterFactory;
 import org.codehaus.plexus.util.ReaderFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -61,9 +62,10 @@ import java.util.Map;
  * @see #executeReport(Locale) <code>abstract executeReport( Locale )</code>
  */
 public abstract class AbstractMavenReport
-    extends AbstractMojo
-    implements MavenMultiPageReport
+    implements org.apache.maven.api.plugin.Mojo, MavenMultiPageReport
 {
+    protected final Logger logger = LoggerFactory.getLogger( getClass() );
+
     /**
      * 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
@@ -76,7 +78,7 @@ public abstract class AbstractMavenReport
      * The Maven Project.
      */
     @Parameter( defaultValue = "${project}", readonly = true, required = true )
-    protected MavenProject project;
+    protected Project project;
 
     /**
      * Specifies the input encoding.
@@ -108,12 +110,12 @@ public abstract class AbstractMavenReport
     /**
      * This method is called when the report generation is invoked directly as a standalone Mojo.
      *
-     * @throws MojoExecutionException if an error occurs when generating the report
-     * @see org.apache.maven.plugin.Mojo#execute()
+     * @throws MojoException if an error occurs when generating the report
+     * @see org.apache.maven.api.plugin.Mojo#execute()
      */
     @Override
     public void execute()
-        throws MojoExecutionException
+        throws MojoException
     {
         if ( !canGenerateReport() )
         {
@@ -155,7 +157,7 @@ public abstract class AbstractMavenReport
         }
         catch ( RendererException | IOException | MavenReportException e )
         {
-            throw new MojoExecutionException(
+            throw new MojoException(
                 "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation.", e );
         }
     }
@@ -172,7 +174,7 @@ public abstract class AbstractMavenReport
         templateProperties.put( "inputEncoding", getInputEncoding() );
         templateProperties.put( "outputEncoding", getOutputEncoding() );
         // Put any of the properties in directly into the Velocity context
-        for ( Map.Entry<Object, Object> entry : getProject().getProperties().entrySet() )
+        for ( Map.Entry<Object, Object> entry : getProject().getModel().getProperties().entrySet() )
         {
             templateProperties.put( (String) entry.getKey(), entry.getValue() );
         }
@@ -208,7 +210,7 @@ public abstract class AbstractMavenReport
     {
         if ( !canGenerateReport() )
         {
-            getLog().info( "This report cannot be generated as part of the current build. "
+            logger.info( "This report cannot be generated as part of the current build. "
                            + "The report name should be referenced in this line of output." );
             return;
         }
@@ -254,7 +256,7 @@ public abstract class AbstractMavenReport
         return outputDirectory.getAbsolutePath();
     }
 
-    protected MavenProject getProject()
+    protected Project getProject()
     {
         return project;
     }