You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/02/07 20:02:02 UTC

[maven-reporting-impl] 01/01: [MSHARED-480] Use maven-site-plugin's site.xml to use site's skin instead of default when run as mojo

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

michaelo pushed a commit to branch use-site.xml
in repository https://gitbox.apache.org/repos/asf/maven-reporting-impl.git

commit d2032091c1bd86c6f52d80a23852aff0e8c0b6ae
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Mon Dec 5 22:42:16 2022 +0100

    [MSHARED-480] Use maven-site-plugin's site.xml to use site's skin instead of default when run as mojo
    
    This closes #15
---
 .../maven/reporting/AbstractMavenReport.java       | 53 ++++++----------------
 1 file changed, 13 insertions(+), 40 deletions(-)

diff --git a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
index c4a5c05..d20add7 100644
--- a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
+++ b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
@@ -25,7 +25,6 @@ import org.apache.maven.archiver.MavenArchiver;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkFactory;
 import org.apache.maven.doxia.site.decoration.DecorationModel;
-import org.apache.maven.doxia.site.decoration.Skin;
 import org.apache.maven.doxia.siterenderer.Renderer;
 import org.apache.maven.doxia.siterenderer.RendererException;
 import org.apache.maven.doxia.siterenderer.RenderingContext;
@@ -88,6 +87,12 @@ public abstract class AbstractMavenReport
     @Parameter( defaultValue = "${project}", readonly = true, required = true )
     protected MavenProject project;
 
+    /**
+     * The reactor projects.
+     */
+    @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true )
+    protected List<MavenProject> reactorProjects;
+
     /**
      * Specifies the input encoding.
      */
@@ -113,21 +118,10 @@ public abstract class AbstractMavenReport
     protected List<ArtifactRepository> remoteRepositories;
 
     /**
-     * The skin to use when the report generation is invoked directly as a standalone Mojo.
-     * <p>
-     * <b>Default value is</b>:
-     * <pre>
-     * &lt;skin&gt;
-     *   &lt;groupId&gt;org.apache.maven.skins&lt;/groupId&gt;
-     *   &lt;artifactId&gt;maven-fluido-skin&lt;/artifactId&gt;
-     *   &lt;version&gt;1.11.1&lt;/version&gt;
-     * &lt;/skin&gt;
-     * </pre>
-     *
-     * @see Skin
+     * Directory containing the <code>site.xml</code> file.
      */
-    @Parameter
-    protected Skin skin;
+    @Parameter( defaultValue = "${basedir}/src/site" )
+    protected File siteDirectory;
 
     /**
      * The locale to use  when the report generation is invoked directly as a standalone Mojo.
@@ -212,7 +206,7 @@ public abstract class AbstractMavenReport
             // copy generated resources also
             getSiteRenderer().copyResources( siteContext, outputDirectory );
         }
-        catch ( RendererException | IOException | MavenReportException e )
+        catch ( RendererException | IOException | MavenReportException | SiteToolException e )
         {
             throw new MojoExecutionException(
                 "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation.", e );
@@ -220,10 +214,10 @@ public abstract class AbstractMavenReport
     }
 
     private SiteRenderingContext createSiteRenderingContext( Locale locale )
-        throws MavenReportException, IOException
+        throws MavenReportException, IOException, SiteToolException
     {
-        DecorationModel decorationModel = new DecorationModel();
-        decorationModel.setSkin( getSkin() );
+        DecorationModel decorationModel = siteTool.getDecorationModel(
+            siteDirectory, locale, project, reactorProjects, localRepository, remoteRepositories );
 
         Map<String, Object> templateProperties = new HashMap<>();
         // We tell the skin that we are rendering in standalone mode
@@ -378,27 +372,6 @@ public abstract class AbstractMavenReport
         return ( outputEncoding == null ) ? WriterFactory.UTF_8 : outputEncoding;
     }
 
-    /**
-     * Gets the skin
-     *
-     * @return the skin for this standalone report
-     */
-    protected Skin getSkin()
-    {
-        if ( skin == null )
-        {
-            Skin skin = new Skin();
-            skin.setGroupId( "org.apache.maven.skins" );
-            skin.setArtifactId( "maven-fluido-skin" );
-            skin.setVersion( "1.11.1" );
-            return skin;
-        }
-        else
-        {
-            return skin;
-        }
-    }
-
     /**
      * Gets the locale
      *