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/04/24 20:31:24 UTC

[maven-site-plugin] branch open-issues updated (aca1ce20 -> aee2c972)

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

michaelo pushed a change to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git


    omit aca1ce20 [MSITE-959] Incorrect assumption of default locale
    omit f061a01d [MSITE-958] Rewrite sitemap generator to a rendender
    omit c7dc8c32 [MSITE-957] Print generation log message in CategorySummaryDocumentRenderer like in ReportDocumentRenderer
    omit ec184231 [MSITE-956] Pass a sub mojo execution to CategorySummaryDocumentRenderer
    omit 58c645e3 [MSITE-955] Improve DoxiaFilter document source log message
    omit 1ed9c2f4 [MSITE-953] Log statistics about rendered non-Doxia documents
    omit 43b04823 [MSITE-954] Introduce SitePluginReportDocumentRenderer marker interface
    omit 1bca5662 [MSITE-952] MultiPageSinkFactory does not strip output name for extension
    omit 37ce1c67 [MSITE-951] Don't abuse report's symbolic output name as filename
    omit 0cd165f8 [MSITE-949] Properly populate DocumentRenderingContext#generator for ReportDocumentRenderer
    omit e8587193 [MSITE-950] Upgrade to Doxia Sitetools to 2.0.0-M8, Maven Reporting API 4.0.0-M6, Maven Reporting Impl/Exec 4.0.0-M7
     add 2c615e5c auto-link MSITE Jira
     new a27217d1 [MSITE-950] Upgrade to Doxia Sitetools to 2.0.0-M8, Maven Reporting API 4.0.0-M6, Maven Reporting Impl/Exec 4.0.0-M7
     new 26802f2f [MSITE-949] Properly populate DocumentRenderingContext#generator for ReportDocumentRenderer
     new fcb097d5 [MSITE-951] Don't abuse report's symbolic output name as filename
     new 6836dee3 [MSITE-952] MultiPageSinkFactory does not strip output name for extension
     new a8e445da [MSITE-954] Introduce SitePluginReportDocumentRenderer marker interface
     new 9077556d [MSITE-953] Log statistics about rendered non-Doxia documents
     new 8410a06a [MSITE-955] Improve DoxiaFilter document source log message
     new 1553a188 [MSITE-956] Pass a sub mojo execution to CategorySummaryDocumentRenderer
     new ca041959 [MSITE-957] Print generation log message in CategorySummaryDocumentRenderer like in ReportDocumentRenderer
     new 39d5e363 [MSITE-958] Rewrite sitemap generator to a rendender
     new aee2c972 [MSITE-959] Incorrect assumption of default locale

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (aca1ce20)
            \
             N -- N -- N   refs/heads/open-issues (aee2c972)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .asf.yaml                                          |  2 ++
 .../site/render/AbstractSiteRenderingMojo.java     |  9 +++-----
 .../render/CategorySummaryDocumentRenderer.java    |  2 +-
 .../apache/maven/plugins/site/render/SiteMojo.java | 24 +++++++---------------
 .../site/render/SitemapDocumentRenderer.java       |  2 +-
 5 files changed, 14 insertions(+), 25 deletions(-)


[maven-site-plugin] 10/11: [MSITE-958] Rewrite sitemap generator to a rendender

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit 39d5e3635329932ed113c99adfe90d3b2c5940f1
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Apr 16 00:24:30 2023 +0200

    [MSITE-958] Rewrite sitemap generator to a rendender
---
 src/it/projects/MSITE-856/verify.bsh               |  35 -----
 src/it/projects/site-sd-lang/pom.xml               |   1 +
 src/it/projects/site-sd-lang/src/site/site.xml     |   1 +
 .../projects/site-sd-lang/src/site/site_de_AT.xml  |   1 +
 .../projects/site-sd-lang/src/site/site_de_DE.xml  |   1 +
 src/it/projects/site-sd-lang/src/site/site_fr.xml  |   1 +
 .../site/render/AbstractSiteRenderingMojo.java     |  28 ++++
 .../apache/maven/plugins/site/render/SiteMojo.java |  14 --
 .../{SiteMap.java => SitemapDocumentRenderer.java} | 156 +++++++++++----------
 9 files changed, 113 insertions(+), 125 deletions(-)

diff --git a/src/it/projects/MSITE-856/verify.bsh b/src/it/projects/MSITE-856/verify.bsh
index 07844732..4ee0e12d 100644
--- a/src/it/projects/MSITE-856/verify.bsh
+++ b/src/it/projects/MSITE-856/verify.bsh
@@ -22,41 +22,6 @@ import org.codehaus.plexus.util.*;
 
 try
 {
-    final File generatedSiteDirectory = new File( basedir, "target/generated-site" );
-    if ( !generatedSiteDirectory.isDirectory() )
-    {
-        System.err.println( "generated-site is missing or not a directory." );
-        return false;
-    }
-
-    File sitemapXdocFile = new File( generatedSiteDirectory, "xdoc/sitemap.xml" );
-    if ( !sitemapXdocFile.isFile() )
-    {
-        System.err.println( "no sitemap.xml!" );
-        return false;
-    }
-
-    String content = FileUtils.fileRead( sitemapXdocFile, "UTF-8" );
-    if ( !content.contains( "<li>My first item</li>" ) )
-    {
-        System.err.println( "\"<li>My first item</li>\" not found in sitemap.xml!" );
-        return false;
-    }
-
-    File sitemapGermanXdocFile = new File( generatedSiteDirectory, "de/xdoc/sitemap.xml" );
-    if ( !sitemapGermanXdocFile.isFile() )
-    {
-        System.err.println( "no German sitemap.xml!" );
-        return false;
-    }
-
-    content = FileUtils.fileRead( sitemapGermanXdocFile, "UTF-8" );
-    if ( !content.contains( "<li>Mein erstes Element</li>" ) )
-    {
-        System.err.println( "\"<li>Mein erstes Element</li>\" not found in German sitemap.xml!" );
-        return false;
-    }
-
     final File siteDirectory = new File( basedir, "target/site" );
     if ( !siteDirectory.isDirectory() )
     {
diff --git a/src/it/projects/site-sd-lang/pom.xml b/src/it/projects/site-sd-lang/pom.xml
index 27937e90..26441c98 100755
--- a/src/it/projects/site-sd-lang/pom.xml
+++ b/src/it/projects/site-sd-lang/pom.xml
@@ -51,6 +51,7 @@ under the License.
           <version>@project.version@</version>
           <configuration>
             <locales>default,en,fr,de,de_DE,de_AT,zh_TW,eo_EU</locales>
+            <generateSitemap>true</generateSitemap>
           </configuration>
         </plugin>
       </plugins>
diff --git a/src/it/projects/site-sd-lang/src/site/site.xml b/src/it/projects/site-sd-lang/src/site/site.xml
index 8dd66a1e..8faa7f9c 100644
--- a/src/it/projects/site-sd-lang/src/site/site.xml
+++ b/src/it/projects/site-sd-lang/src/site/site.xml
@@ -32,6 +32,7 @@ under the License.
       <item name="Accueil" href="index.html" />
       <item name="Contacts" href="contact.html" />
       <item name="Retour" href="../index.html" />
+      <item name="Sitemap" href="sitemap.html" />
     </menu>
     <menu name="Doc">
       <item name="specs" href="doc.html" />
diff --git a/src/it/projects/site-sd-lang/src/site/site_de_AT.xml b/src/it/projects/site-sd-lang/src/site/site_de_AT.xml
index b211abdd..f21304d0 100644
--- a/src/it/projects/site-sd-lang/src/site/site_de_AT.xml
+++ b/src/it/projects/site-sd-lang/src/site/site_de_AT.xml
@@ -32,6 +32,7 @@ under the License.
     <menu name="${project.name}">
       <item name="Einstieg" href="index.html" />
       <item name="J�nner" href="jan.html" />
+      <item name="Navigations�bersicht" href="sitemap.html" />
     </menu>
     <menu ref="reports"/>
   </body>
diff --git a/src/it/projects/site-sd-lang/src/site/site_de_DE.xml b/src/it/projects/site-sd-lang/src/site/site_de_DE.xml
index 60f5822b..8952db43 100644
--- a/src/it/projects/site-sd-lang/src/site/site_de_DE.xml
+++ b/src/it/projects/site-sd-lang/src/site/site_de_DE.xml
@@ -32,6 +32,7 @@ under the License.
     <menu name="${project.name}">
       <item name="Einstieg" href="index.html" />
       <item name="Januar" href="jan.html" />
+      <item name="Navigations�bersicht" href="sitemap.html" />
     </menu>
     <menu ref="reports"/>
   </body>
diff --git a/src/it/projects/site-sd-lang/src/site/site_fr.xml b/src/it/projects/site-sd-lang/src/site/site_fr.xml
index f24d2b3e..55dc932f 100644
--- a/src/it/projects/site-sd-lang/src/site/site_fr.xml
+++ b/src/it/projects/site-sd-lang/src/site/site_fr.xml
@@ -33,6 +33,7 @@ under the License.
       <item name="Accueil" href="index.html" />
       <item name="Contacts" href="contact.html" />
       <item name="Retour" href="../index.html" />
+      <item name="Sitemap" href="sitemap.html" />
     </menu>
     <menu name="Doc">
       <item name="specs" href="doc.html" />
diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index 7ce91550..efa1d98e 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -142,6 +142,14 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
     @Parameter(property = "generateProjectInfo", defaultValue = "true")
     private boolean generateProjectInfo;
 
+    /**
+     * Generate a sitemap. The result will be a "sitemap.html" file at the site root.
+     *
+     * @since 2.1
+     */
+    @Parameter(property = "generateSitemap", defaultValue = "false")
+    private boolean generateSitemap;
+
     /**
      * Specifies the input encoding.
      *
@@ -455,6 +463,26 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
                 getLog().info("Skipped \"" + title + "\" report; file \"" + filename + "\" already exists.");
             }
         }
+
+        if (generateSitemap) {
+            MojoExecution subMojoExecution =
+                    new MojoExecution(mojoExecution.getPlugin(), "sitemap", mojoExecution.getExecutionId());
+            DocumentRenderingContext docRenderingContext = new DocumentRenderingContext(
+                    siteDirectory,
+                    subMojoExecution.getGoal(),
+                    subMojoExecution.getPlugin().getId() + ':' + subMojoExecution.getGoal());
+            String title = i18n.getString("site-plugin", locale, "site.sitemap.title");
+            DocumentRenderer docRenderer = new SitemapDocumentRenderer(
+                    subMojoExecution, docRenderingContext, title, context.getSiteModel(), i18n, getLog());
+
+            String filename = docRenderer.getOutputName();
+            if (!documents.containsKey(filename)) {
+                documents.put(filename, docRenderer);
+            } else {
+                getLog().info("Skipped \"" + title + "\" report; file \"" + filename + "\" already exists.");
+            }
+        }
+
         return documents;
     }
 
diff --git a/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java b/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
index 5725e026..6325b795 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
@@ -71,14 +71,6 @@ public class SiteMojo extends AbstractSiteRenderingMojo {
     @Parameter(property = "generateReports", defaultValue = "true")
     private boolean generateReports;
 
-    /**
-     * Generate a sitemap. The result will be a "sitemap.html" file at the site root.
-     *
-     * @since 2.1
-     */
-    @Parameter(property = "generateSitemap", defaultValue = "false")
-    private boolean generateSitemap;
-
     /**
      * Whether to validate xml input documents. If set to true, <strong>all</strong> input documents in xml format (in
      * particular xdoc and fml) will be validated and any error will lead to a build failure.
@@ -170,12 +162,6 @@ public class SiteMojo extends AbstractSiteRenderingMojo {
         // 2. then non-Doxia documents (e.g., reports)
         renderNonDoxiaDocuments(nonDoxiaDocuments, context, outputDir);
 
-        if (generateSitemap) {
-            getLog().info("Generating Sitemap");
-
-            new SiteMap(getOutputEncoding(), i18n).generate(context.getSiteModel(), generatedSiteDirectory, locale);
-        }
-
         // 3. Generated docs must be (re-)done afterwards as they are often generated by reports
         context.getSiteDirectories().clear();
         if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
diff --git a/src/main/java/org/apache/maven/plugins/site/render/SiteMap.java b/src/main/java/org/apache/maven/plugins/site/render/SitemapDocumentRenderer.java
similarity index 52%
rename from src/main/java/org/apache/maven/plugins/site/render/SiteMap.java
rename to src/main/java/org/apache/maven/plugins/site/render/SitemapDocumentRenderer.java
index afcce6bd..d08a210a 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/SiteMap.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/SitemapDocumentRenderer.java
@@ -18,111 +18,87 @@
  */
 package org.apache.maven.plugins.site.render;
 
-import java.io.File;
-import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.Writer;
 import java.util.List;
 import java.util.Locale;
 
-import org.apache.maven.doxia.module.xdoc.XdocSinkFactory;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.site.Menu;
 import org.apache.maven.doxia.site.MenuItem;
 import org.apache.maven.doxia.site.SiteModel;
-import org.apache.maven.doxia.tools.SiteTool;
+import org.apache.maven.doxia.siterenderer.DocumentRenderingContext;
+import org.apache.maven.doxia.siterenderer.RendererException;
+import org.apache.maven.doxia.siterenderer.SiteRenderer;
+import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
+import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.logging.Log;
 import org.codehaus.plexus.i18n.I18N;
 
+import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
+
 /**
- * Generate a sitemap.
+ * Renders a sitemap report.
  *
  * @author ltheussl
  *
  * @since 2.1
  */
-public class SiteMap {
+public class SitemapDocumentRenderer implements SitePluginReportDocumentRenderer {
+    private DocumentRenderingContext docRenderingContext;
 
-    private String encoding;
-    private I18N i18n;
+    private final String reportMojoInfo;
 
-    /**
-     * Constructor sets default values.
-     *
-     * @param encoding the default encoding to use when writing the output file.
-     * @param i18n the default I18N for translations.
-     */
-    public SiteMap(String encoding, I18N i18n) {
-        this.encoding = encoding;
-        this.i18n = i18n;
-    }
+    String title;
 
-    /**
-     * Get the value of i18n.
-     *
-     * @return the value of i18n.
-     */
-    public I18N getI18n() {
-        return i18n;
-    }
+    private SiteModel siteModel;
 
-    /**
-     * Set the value of i18n.
-     *
-     * @param i18n new value of i18n.
-     */
-    public void setI18n(I18N i18n) {
-        this.i18n = i18n;
-    }
+    private I18N i18n;
 
-    /**
-     * Get the encoding to use when writing the output file.
-     *
-     * @return the value of encoding.
-     */
-    public String getEncoding() {
-        return encoding;
+    private final Log log;
+
+    public SitemapDocumentRenderer(
+            MojoExecution mojoExecution,
+            DocumentRenderingContext docRenderingContext,
+            String title,
+            SiteModel siteModel,
+            I18N i18n,
+            Log log) {
+        this.docRenderingContext = docRenderingContext;
+        this.reportMojoInfo = mojoExecution.getPlugin().getArtifactId()
+                + ':'
+                + mojoExecution.getPlugin().getVersion()
+                + ':'
+                + mojoExecution.getGoal();
+        this.title = title;
+        this.siteModel = siteModel;
+        this.i18n = i18n;
+        this.log = log;
     }
 
-    /**
-     * Set the encoding to use when writing the output file.
-     *
-     * @param enc new value of encoding.
-     */
-    public void setEncoding(String enc) {
-        this.encoding = enc;
-    }
+    public void renderDocument(Writer writer, SiteRenderer siteRenderer, SiteRenderingContext siteRenderingContext)
+            throws RendererException, FileNotFoundException {
+        Locale locale = siteRenderingContext.getLocale();
 
-    /**
-     * Generates a sitemap.xml in targetDir/(locale/)?xdoc/.
-     * This is a valid xdoc document that can be processed by a Doxia parser.
-     * The file lists all the menus and menu items of the SiteModel in expanded form.
-     *
-     * @param siteModel the SiteModel to extract the menus from.
-     * @param targetDir the target output directory. The file will be created in targetDir/(locale/)?xdoc/.
-     * @param locale the Locale for the result.
-     *
-     * @throws IOException if the file cannot be ceated.
-     */
-    public void generate(SiteModel siteModel, File targetDir, Locale locale) throws IOException {
-        File outputDir;
-        if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
-            outputDir = new File(new File(targetDir, locale.toString()), "xdoc");
-        } else {
-            outputDir = new File(targetDir, "xdoc");
-        }
-        Sink sink = new XdocSinkFactory().createSink(outputDir, "sitemap.xml", encoding);
+        String msg = "Generating \"" + buffer().strong(title) + "\" report";
+        // CHECKSTYLE_OFF: MagicNumber
+        log.info((StringUtils.rightPad(msg, 40) + buffer().strong(" --- ").mojo(reportMojoInfo)));
+        // CHECKSTYLE_ON: MagicNumber
 
-        try {
-            extract(siteModel, sink, locale);
-        } finally {
-            sink.close();
-        }
-    }
+        SiteRendererSink sink = new SiteRendererSink(docRenderingContext);
 
-    private void extract(SiteModel siteModel, Sink sink, Locale locale) {
         sink.head();
+
         sink.title();
-        sink.text(i18n.getString("site-plugin", locale, "site.sitemap.title"));
+
+        sink.text(title);
+
         sink.title_();
+
         sink.head_();
+
         sink.body();
 
         sink.section1();
@@ -147,7 +123,14 @@ public class SiteMap {
         }
 
         sink.section1_();
+
         sink.body_();
+
+        sink.flush();
+
+        sink.close();
+
+        siteRenderer.mergeDocumentIntoSite(writer, sink, siteRenderingContext);
     }
 
     private static void extractItems(List<MenuItem> items, Sink sink) {
@@ -178,4 +161,25 @@ public class SiteMap {
     private static String relativePath(String href) {
         return href.startsWith("/") ? "." + href : href;
     }
+
+    public String getOutputName() {
+        return docRenderingContext.getOutputName();
+    }
+
+    public DocumentRenderingContext getRenderingContext() {
+        return docRenderingContext;
+    }
+
+    public boolean isOverwrite() {
+        return true;
+    }
+
+    public boolean isExternalReport() {
+        return false;
+    }
+
+    @Override
+    public String getReportMojoInfo() {
+        return reportMojoInfo;
+    }
 }


[maven-site-plugin] 11/11: [MSITE-959] Incorrect assumption of default locale

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit aee2c9727262bbc52206bf208d5c429cffc14bcf
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Tue Apr 18 13:56:47 2023 +0200

    [MSITE-959] Incorrect assumption of default locale
---
 .../apache/maven/plugins/site/deploy/AbstractDeployMojo.java   |  6 ++----
 .../plugins/site/descriptor/AbstractSiteDescriptorMojo.java    |  8 ++------
 .../java/org/apache/maven/plugins/site/render/SiteMojo.java    |  7 +++----
 .../java/org/apache/maven/plugins/site/run/SiteRunMojo.java    | 10 ++++------
 4 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
index b932175a..b7f09031 100644
--- a/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
@@ -28,6 +28,7 @@ import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.doxia.site.inheritance.URIPathDescriptor;
+import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.DistributionManagement;
@@ -357,11 +358,8 @@ public abstract class AbstractDeployMojo extends AbstractSiteMojo implements Con
 
             getLog().info("Pushing " + inputDirectory);
 
-            // Default is first in the list
-            final Locale defaultLocale = localesList.get(0);
-
             for (Locale locale : localesList) {
-                if (!locale.equals(defaultLocale)) {
+                if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
                     getLog().info("   >>> to " + appendSlash(repository.getUrl()) + locale + "/" + relativeDir);
 
                     wagon.putDirectory(new File(inputDirectory, locale.toString()), locale + "/" + relativeDir);
diff --git a/src/main/java/org/apache/maven/plugins/site/descriptor/AbstractSiteDescriptorMojo.java b/src/main/java/org/apache/maven/plugins/site/descriptor/AbstractSiteDescriptorMojo.java
index b72e0230..a2f3f62d 100644
--- a/src/main/java/org/apache/maven/plugins/site/descriptor/AbstractSiteDescriptorMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/descriptor/AbstractSiteDescriptorMojo.java
@@ -24,6 +24,7 @@ import java.util.Locale;
 
 import org.apache.maven.doxia.site.SiteModel;
 import org.apache.maven.doxia.site.inheritance.SiteModelInheritanceAssembler;
+import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.doxia.tools.SiteToolException;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Component;
@@ -100,13 +101,8 @@ public abstract class AbstractSiteDescriptorMojo extends AbstractSiteMojo {
             if (url == null) {
                 getLog().warn("No project URL defined - site links will not be relativized!");
             } else {
-                List<Locale> localesList = getLocales();
-
-                // Default is first in the list
-                Locale defaultLocale = localesList.get(0);
-
                 // MSITE-658
-                final String localeUrl = !locale.equals(defaultLocale) ? append(url, locale.toString()) : url;
+                final String localeUrl = !locale.equals(SiteTool.DEFAULT_LOCALE) ? append(url, locale.toString()) : url;
 
                 getLog().info("Relativizing site links with respect to localized project URL: " + localeUrl);
                 assembler.resolvePaths(siteModel, localeUrl);
diff --git a/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java b/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
index 6325b795..96340f09 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
@@ -105,13 +105,12 @@ public class SiteMojo extends AbstractSiteRenderingMojo {
         try {
             List<Locale> localesList = getLocales();
 
-            // Default is first in the list
-            Locale defaultLocale = localesList.get(0);
-
             for (Locale locale : localesList) {
                 getLog().info("Rendering site for "
                         + buffer().strong(
-                                        (!locale.equals(defaultLocale) ? "locale '" + locale + "'" : "default locale"))
+                                        (!locale.equals(SiteTool.DEFAULT_LOCALE)
+                                                ? "locale '" + locale + "'"
+                                                : "default locale"))
                                 .toString());
                 renderLocale(locale, reports, localesList);
             }
diff --git a/src/main/java/org/apache/maven/plugins/site/run/SiteRunMojo.java b/src/main/java/org/apache/maven/plugins/site/run/SiteRunMojo.java
index 6d254bf1..5d7381a6 100644
--- a/src/main/java/org/apache/maven/plugins/site/run/SiteRunMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/run/SiteRunMojo.java
@@ -30,6 +30,7 @@ import java.util.Map;
 
 import org.apache.maven.doxia.siterenderer.DocumentRenderer;
 import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
+import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -130,9 +131,6 @@ public class SiteRunMojo extends AbstractSiteRenderingMojo {
         List<Locale> localesList = getLocales();
         webapp.setAttribute(DoxiaFilter.LOCALES_LIST_KEY, localesList);
 
-        // Default is first in the list
-        Locale defaultLocale = localesList.get(0);
-
         try {
             Map<String, DoxiaBean> i18nDoxiaContexts = new HashMap<>();
 
@@ -147,20 +145,20 @@ public class SiteRunMojo extends AbstractSiteRenderingMojo {
                 i18nGeneratedSiteContext.getSiteDirectories().clear();
 
                 Map<String, DocumentRenderer> i18nDocuments = locateDocuments(i18nContext, reports, locale);
-                if (!defaultLocale.equals(locale)) {
+                if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
                     i18nGeneratedSiteContext.addSiteDirectory(new File(generatedSiteDirectory, locale.toString()));
                 } else {
                     i18nGeneratedSiteContext.addSiteDirectory(generatedSiteDirectory);
                 }
                 DoxiaBean doxiaBean = new DoxiaBean(i18nContext, i18nDocuments, i18nGeneratedSiteContext);
 
-                if (!defaultLocale.equals(locale)) {
+                if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
                     i18nDoxiaContexts.put(locale.toString(), doxiaBean);
                 } else {
                     i18nDoxiaContexts.put("default", doxiaBean);
                 }
 
-                if (!defaultLocale.equals(locale)) {
+                if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
                     siteRenderer.copyResources(i18nContext, new File(tempWebappDirectory, locale.toString()));
                 } else {
                     siteRenderer.copyResources(i18nContext, tempWebappDirectory);


[maven-site-plugin] 04/11: [MSITE-952] MultiPageSinkFactory does not strip output name for extension

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit 6836dee354abcb2df19d049f78e1b9c0e069cbf4
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 20:08:52 2023 +0200

    [MSITE-952] MultiPageSinkFactory does not strip output name for extension
---
 .../apache/maven/plugins/site/render/ReportDocumentRenderer.java    | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/site/render/ReportDocumentRenderer.java b/src/main/java/org/apache/maven/plugins/site/render/ReportDocumentRenderer.java
index f0f855e7..ef8d7cb3 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/ReportDocumentRenderer.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/ReportDocumentRenderer.java
@@ -122,13 +122,15 @@ public class ReportDocumentRenderer implements DocumentRenderer {
         @Override
         public Sink createSink(File outputDir, String outputName) {
             // Create a new document rendering context, similar to the main one, but with a different output name
-            String outputRelativeToTargetSite = PathTool.getRelativeFilePath(
+            String document = PathTool.getRelativeFilePath(
                     report.getReportOutputDirectory().getPath(), new File(outputDir, outputName).getPath());
+            // Remove .html suffix since we know that we are in Site Renderer context
+            document = document.substring(0, document.lastIndexOf('.'));
 
             DocumentRenderingContext subSinkContext = new DocumentRenderingContext(
                     docRenderingContext.getBasedir(),
                     docRenderingContext.getBasedirRelativePath(),
-                    outputRelativeToTargetSite,
+                    document,
                     docRenderingContext.getParserId(),
                     docRenderingContext.getExtension(),
                     docRenderingContext.isEditable(),


[maven-site-plugin] 09/11: [MSITE-957] Print generation log message in CategorySummaryDocumentRenderer like in ReportDocumentRenderer

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit ca04195938a3632d041ebb5a8d50868790a4fecd
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 22:25:08 2023 +0200

    [MSITE-957] Print generation log message in CategorySummaryDocumentRenderer like in ReportDocumentRenderer
---
 .../plugins/site/render/CategorySummaryDocumentRenderer.java      | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/main/java/org/apache/maven/plugins/site/render/CategorySummaryDocumentRenderer.java b/src/main/java/org/apache/maven/plugins/site/render/CategorySummaryDocumentRenderer.java
index c9277c6b..1f8bba4d 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/CategorySummaryDocumentRenderer.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/CategorySummaryDocumentRenderer.java
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.maven.doxia.siterenderer.DocumentRenderingContext;
 import org.apache.maven.doxia.siterenderer.RendererException;
 import org.apache.maven.doxia.siterenderer.SiteRenderer;
@@ -34,6 +35,8 @@ import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.reporting.MavenReport;
 import org.codehaus.plexus.i18n.I18N;
 
+import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
+
 /**
  * Renders a Maven report.
  *
@@ -81,6 +84,11 @@ public class CategorySummaryDocumentRenderer implements SitePluginReportDocument
 
     public void renderDocument(Writer writer, SiteRenderer siteRenderer, SiteRenderingContext siteRenderingContext)
             throws RendererException, FileNotFoundException {
+        String msg = "Generating \"" + buffer().strong(title) + "\" report";
+        // CHECKSTYLE_OFF: MagicNumber
+        log.info((StringUtils.rightPad(msg, 40) + buffer().strong(" --- ").mojo(reportMojoInfo)));
+        // CHECKSTYLE_ON: MagicNumber
+
         SiteRendererSink sink = new SiteRendererSink(docRenderingContext);
 
         sink.head();


[maven-site-plugin] 01/11: [MSITE-950] Upgrade to Doxia Sitetools to 2.0.0-M8, Maven Reporting API 4.0.0-M6, Maven Reporting Impl/Exec 4.0.0-M7

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit a27217d1ba83f404de8bf606300c853e5ccdc6f8
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 19:33:35 2023 +0200

    [MSITE-950] Upgrade to Doxia Sitetools to 2.0.0-M8, Maven Reporting API 4.0.0-M6, Maven Reporting Impl/Exec 4.0.0-M7
---
 pom.xml                                                           | 8 ++++----
 .../maven/plugins/site/render/AbstractSiteRenderingMojo.java      | 8 ++++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 60401bdb..1d279527 100644
--- a/pom.xml
+++ b/pom.xml
@@ -198,7 +198,7 @@ under the License.
     <!-- for dependencies -->
     <jettyVersion>9.4.50.v20221201</jettyVersion>
     <doxiaVersion>2.0.0-M6</doxiaVersion>
-    <doxiaSitetoolsVersion>2.0.0-M7</doxiaSitetoolsVersion>
+    <doxiaSitetoolsVersion>2.0.0-M8</doxiaSitetoolsVersion>
     <wagonVersion>3.5.3</wagonVersion>
     <slf4jVersion>1.7.36</slf4jVersion>
     <!-- for ITs -->
@@ -209,7 +209,7 @@ under the License.
     <projectInfoReportsPluginVersion>3.4.2</projectInfoReportsPluginVersion>
     <surefirePluginVersion>3.0.0</surefirePluginVersion>
     <mavenPluginPluginVersion>3.8.1</mavenPluginPluginVersion>
-    <mavenReportingImplVersion>4.0.0-M6</mavenReportingImplVersion>
+    <mavenReportingImplVersion>4.0.0-M7</mavenReportingImplVersion>
     <fluidoSkinVersion>2.0.0-M3</fluidoSkinVersion>
     <surefire.version>3.0.0</surefire.version>
     <project.build.outputTimestamp>2023-04-08T16:17:12Z</project.build.outputTimestamp>
@@ -220,12 +220,12 @@ under the License.
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-api</artifactId>
-      <version>4.0.0-M5</version>
+      <version>4.0.0-M6</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-exec</artifactId>
-      <version>2.0.0-M6</version>
+      <version>2.0.0-M7</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index 2b5d81e6..26010062 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -46,6 +46,7 @@ import org.apache.maven.doxia.tools.SiteToolException;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.Reporting;
+import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
@@ -119,6 +120,12 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
     @Parameter(defaultValue = "${session}", readonly = true, required = true)
     protected MavenSession mavenSession;
 
+    /**
+     * The mojo execution
+     */
+    @Parameter(defaultValue = "${mojoExecution}", readonly = true, required = true)
+    protected MojoExecution mojoExecution;
+
     /**
      * replaces previous reportPlugins parameter, that was injected by Maven core from
      * reporting section: but this new configuration format has been abandoned.
@@ -192,6 +199,7 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
     protected List<MavenReportExecution> getReports() throws MojoExecutionException {
         MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
         mavenReportExecutorRequest.setMavenSession(mavenSession);
+        mavenReportExecutorRequest.setExecutionId(mojoExecution.getExecutionId());
         mavenReportExecutorRequest.setProject(project);
         mavenReportExecutorRequest.setReportPlugins(getReportingPlugins());
 


[maven-site-plugin] 03/11: [MSITE-951] Don't abuse report's symbolic output name as filename

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit fcb097d592d245701b9c1505c558844e14e44115
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 19:48:16 2023 +0200

    [MSITE-951] Don't abuse report's symbolic output name as filename
---
 .../site/render/AbstractSiteRenderingMojo.java     | 30 ++++++++++++----------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index 82a4eed3..dc4c7ce6 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -334,21 +334,21 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
         for (MavenReportExecution mavenReportExecution : reports) {
             MavenReport report = mavenReportExecution.getMavenReport();
 
-            String outputName = report.getOutputName() + ".html";
+            String outputName = report.getOutputName();
+            String filename = outputName + ".html";
 
             // Always add the report to the menu, see MSITE-150
-            reportsByOutputName.put(report.getOutputName(), report);
+            reportsByOutputName.put(outputName, report);
 
-            if (documents.containsKey(outputName)) {
-                String reportMojoInfo = (mavenReportExecution.getGoal() == null)
+            if (documents.containsKey(filename)) {
+                String reportMojoInfo = mavenReportExecution.getGoal() == null
                         ? ""
-                        : (" ("
-                                + mavenReportExecution.getPlugin().getArtifactId() + ':'
+                        : (" (" + mavenReportExecution.getPlugin().getArtifactId() + ':'
                                 + mavenReportExecution.getPlugin().getVersion() + ':' + mavenReportExecution.getGoal()
                                 + ')');
 
                 getLog().info("Skipped \"" + report.getName(locale) + "\" report" + reportMojoInfo + ", file \""
-                        + outputName + "\" already exists.");
+                        + filename + "\" already exists.");
             } else {
                 String generator = mavenReportExecution.getGoal() == null
                         ? null
@@ -357,7 +357,7 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
                         new DocumentRenderingContext(siteDirectory, outputName, generator);
                 DocumentRenderer docRenderer =
                         new ReportDocumentRenderer(mavenReportExecution, docRenderingContext, getLog());
-                documents.put(outputName, docRenderer);
+                documents.put(filename, docRenderer);
             }
         }
         return reportsByOutputName;
@@ -423,10 +423,11 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
             DocumentRenderer docRenderer = new CategorySummaryDocumentRenderer(
                     docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());
 
-            if (!documents.containsKey(docRenderer.getOutputName())) {
-                documents.put(docRenderer.getOutputName(), docRenderer);
+            String filename = docRenderer.getOutputName();
+            if (!documents.containsKey(filename)) {
+                documents.put(filename, docRenderer);
             } else {
-                getLog().info("Category summary '" + docRenderer.getOutputName() + "' skipped; already exists");
+                getLog().info("Skipped \"" + title + "\" report; file \"" + filename + "\" already exists.");
             }
         }
 
@@ -441,10 +442,11 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
             DocumentRenderer docRenderer = new CategorySummaryDocumentRenderer(
                     docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());
 
-            if (!documents.containsKey(docRenderer.getOutputName())) {
-                documents.put(docRenderer.getOutputName(), docRenderer);
+            String filename = docRenderer.getOutputName();
+            if (!documents.containsKey(filename)) {
+                documents.put(filename, docRenderer);
             } else {
-                getLog().info("Category summary '" + docRenderer.getOutputName() + "' skipped; already exists");
+                getLog().info("Skipped \"" + title + "\" report; file \"" + filename + "\" already exists.");
             }
         }
         return documents;


[maven-site-plugin] 06/11: [MSITE-953] Log statistics about rendered non-Doxia documents

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit 9077556d8214cbd22720763484fd7eb02c4da26c
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 20:32:42 2023 +0200

    [MSITE-953] Log statistics about rendered non-Doxia documents
---
 .../apache/maven/plugins/site/render/SiteMojo.java | 48 ++++++++++++++++++++--
 1 file changed, 45 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java b/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
index a87d4f9b..5725e026 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/SiteMojo.java
@@ -159,16 +159,16 @@ public class SiteMojo extends AbstractSiteRenderingMojo {
         siteRenderer.copyResources(context, outputDir);
 
         // 1. render Doxia documents first
-        List<DocumentRenderer> reportDocuments = renderDoxiaDocuments(documents, context, outputDir, false);
+        List<DocumentRenderer> nonDoxiaDocuments = renderDoxiaDocuments(documents, context, outputDir, false);
 
-        // 2. then reports
         // prepare external reports
         for (MavenReportExecution mavenReportExecution : reports) {
             MavenReport report = mavenReportExecution.getMavenReport();
             report.setReportOutputDirectory(outputDir);
         }
 
-        siteRenderer.render(reportDocuments, context, outputDir);
+        // 2. then non-Doxia documents (e.g., reports)
+        renderNonDoxiaDocuments(nonDoxiaDocuments, context, outputDir);
 
         if (generateSitemap) {
             getLog().info("Generating Sitemap");
@@ -254,6 +254,48 @@ public class SiteMojo extends AbstractSiteRenderingMojo {
         return nonDoxiaDocuments;
     }
 
+    /**
+     * Render non-Doxia documents (e.g., reports) from the list given
+     *
+     * @param documents a collection of documents containing non-Doxia source files
+     */
+    private void renderNonDoxiaDocuments(List<DocumentRenderer> documents, SiteRenderingContext context, File outputDir)
+            throws RendererException, IOException {
+        Map<String, Integer> counts = new TreeMap<>();
+
+        for (DocumentRenderer doc : documents) {
+            String type;
+            if (doc instanceof ReportDocumentRenderer || doc instanceof SitePluginReportDocumentRenderer) {
+                type = "report";
+            } else {
+                type = "other";
+            }
+
+            Integer count = counts.get(type);
+            if (count == null) {
+                count = 1;
+            } else {
+                count++;
+            }
+            counts.put(type, count);
+        }
+
+        if (documents.size() > 0) {
+            for (Map.Entry<String, Integer> entry : counts.entrySet()) {
+                String type = entry.getKey();
+                Integer count = entry.getValue();
+
+                MessageBuilder mb = buffer();
+                mb.a("Rendering ");
+                mb.strong(count + " " + type + " document" + (count > 1 ? "s" : ""));
+
+                getLog().info(mb.toString());
+            }
+
+            siteRenderer.render(documents, context, outputDir);
+        }
+    }
+
     private File getOutputDirectory(Locale locale) {
         File file;
         if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {


[maven-site-plugin] 07/11: [MSITE-955] Improve DoxiaFilter document source log message

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit 8410a06a76e3a46923a5a5997c1765916d1f5c09
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 22:05:41 2023 +0200

    [MSITE-955] Improve DoxiaFilter document source log message
---
 .../org/apache/maven/plugins/site/run/DoxiaFilter.java   | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/site/run/DoxiaFilter.java b/src/main/java/org/apache/maven/plugins/site/run/DoxiaFilter.java
index 342118f1..508744b3 100644
--- a/src/main/java/org/apache/maven/plugins/site/run/DoxiaFilter.java
+++ b/src/main/java/org/apache/maven/plugins/site/run/DoxiaFilter.java
@@ -42,6 +42,7 @@ import org.apache.maven.doxia.siterenderer.SiteRenderer;
 import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
 import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.plugins.site.render.ReportDocumentRenderer;
+import org.apache.maven.plugins.site.render.SitePluginReportDocumentRenderer;
 import org.eclipse.jetty.http.MimeTypes;
 
 import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
@@ -191,13 +192,18 @@ public class DoxiaFilter implements Filter {
     private void logDocumentRenderer(String path, String locale, DocumentRenderer docRenderer) {
         String source;
         if (docRenderer instanceof DoxiaDocumentRenderer) {
-            DoxiaDocumentRenderer doxiaDocumentRenderer = (DoxiaDocumentRenderer) docRenderer;
-            source = doxiaDocumentRenderer.getRenderingContext().getInputName();
+            source = docRenderer.getRenderingContext().getDoxiaSourcePath();
         } else if (docRenderer instanceof ReportDocumentRenderer) {
-            ReportDocumentRenderer reportDocumentRenderer = (ReportDocumentRenderer) docRenderer;
-            source = reportDocumentRenderer.getReportMojoInfo();
+            source = ((ReportDocumentRenderer) docRenderer).getReportMojoInfo();
+            if (source == null) {
+                source = "(unknown)";
+            }
+        } else if (docRenderer instanceof SitePluginReportDocumentRenderer) {
+            source = ((SitePluginReportDocumentRenderer) docRenderer).getReportMojoInfo();
         } else {
-            source = docRenderer.getClass().getName();
+            source = docRenderer.getRenderingContext().getGenerator() != null
+                    ? docRenderer.getRenderingContext().getGenerator()
+                    : docRenderer.getClass().getName();
         }
         String localizedPath = !locale.equals(SiteTool.DEFAULT_LOCALE.toString()) ? locale + "/" + path : path;
         String localizedSource = source


[maven-site-plugin] 02/11: [MSITE-949] Properly populate DocumentRenderingContext#generator for ReportDocumentRenderer

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit 26802f2f19f8a126105f74db4084fd5d3ef311c0
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 17:57:26 2023 +0200

    [MSITE-949] Properly populate DocumentRenderingContext#generator for ReportDocumentRenderer
---
 .../maven/plugins/site/render/AbstractSiteRenderingMojo.java | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index 26010062..82a4eed3 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -350,15 +350,11 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
                 getLog().info("Skipped \"" + report.getName(locale) + "\" report" + reportMojoInfo + ", file \""
                         + outputName + "\" already exists.");
             } else {
-                String reportMojoInfo = mavenReportExecution.getPlugin().getGroupId()
-                        + ':'
-                        + mavenReportExecution.getPlugin().getArtifactId()
-                        + ':'
-                        + mavenReportExecution.getPlugin().getVersion()
-                        + ':'
-                        + mavenReportExecution.getGoal();
+                String generator = mavenReportExecution.getGoal() == null
+                        ? null
+                        : mavenReportExecution.getPlugin().getId() + ':' + mavenReportExecution.getGoal();
                 DocumentRenderingContext docRenderingContext =
-                        new DocumentRenderingContext(siteDirectory, outputName, reportMojoInfo);
+                        new DocumentRenderingContext(siteDirectory, outputName, generator);
                 DocumentRenderer docRenderer =
                         new ReportDocumentRenderer(mavenReportExecution, docRenderingContext, getLog());
                 documents.put(outputName, docRenderer);


[maven-site-plugin] 05/11: [MSITE-954] Introduce SitePluginReportDocumentRenderer marker interface

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit a8e445da2f1ee39d52a2beb17d71f11950a9ffaf
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 20:35:21 2023 +0200

    [MSITE-954] Introduce SitePluginReportDocumentRenderer marker interface
---
 .../render/SitePluginReportDocumentRenderer.java   | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/main/java/org/apache/maven/plugins/site/render/SitePluginReportDocumentRenderer.java b/src/main/java/org/apache/maven/plugins/site/render/SitePluginReportDocumentRenderer.java
new file mode 100644
index 00000000..25e6d673
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/site/render/SitePluginReportDocumentRenderer.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.site.render;
+
+import org.apache.maven.doxia.siterenderer.DocumentRenderer;
+
+public interface SitePluginReportDocumentRenderer extends DocumentRenderer {
+
+    String getReportMojoInfo();
+}


[maven-site-plugin] 08/11: [MSITE-956] Pass a sub mojo execution to CategorySummaryDocumentRenderer

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch open-issues
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit 1553a188e3b2de8df394705d38d6f250f37e6c3e
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 15 22:22:55 2023 +0200

    [MSITE-956] Pass a sub mojo execution to CategorySummaryDocumentRenderer
---
 .../site/render/AbstractSiteRenderingMojo.java     | 24 +++++++++----------
 .../render/CategorySummaryDocumentRenderer.java    | 27 ++++++++++++----------
 2 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index dc4c7ce6..7ce91550 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -49,7 +49,6 @@ import org.apache.maven.model.Reporting;
 import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.site.descriptor.AbstractSiteDescriptorMojo;
@@ -414,14 +413,17 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
         if (categories.containsKey(MavenReport.CATEGORY_PROJECT_INFORMATION) && generateProjectInfo) {
             // add "Project Information" category summary document
             List<MavenReport> categoryReports = categories.get(MavenReport.CATEGORY_PROJECT_INFORMATION);
-
+            MojoExecution subMojoExecution =
+                    new MojoExecution(mojoExecution.getPlugin(), "project-info", mojoExecution.getExecutionId());
             DocumentRenderingContext docRenderingContext = new DocumentRenderingContext(
-                    siteDirectory, "project-info.html", getSitePluginInfo() + ":CategorySummaryDocumentRenderer");
+                    siteDirectory,
+                    subMojoExecution.getGoal(),
+                    subMojoExecution.getPlugin().getId() + ':' + subMojoExecution.getGoal());
             String title = i18n.getString("site-plugin", locale, "report.information.title");
             String desc1 = i18n.getString("site-plugin", locale, "report.information.description1");
             String desc2 = i18n.getString("site-plugin", locale, "report.information.description2");
             DocumentRenderer docRenderer = new CategorySummaryDocumentRenderer(
-                    docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());
+                    subMojoExecution, docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());
 
             String filename = docRenderer.getOutputName();
             if (!documents.containsKey(filename)) {
@@ -434,13 +436,17 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
         if (categories.containsKey(MavenReport.CATEGORY_PROJECT_REPORTS)) {
             // add "Project Reports" category summary document
             List<MavenReport> categoryReports = categories.get(MavenReport.CATEGORY_PROJECT_REPORTS);
+            MojoExecution subMojoExecution =
+                    new MojoExecution(mojoExecution.getPlugin(), "project-reports", mojoExecution.getExecutionId());
             DocumentRenderingContext docRenderingContext = new DocumentRenderingContext(
-                    siteDirectory, "project-reports.html", getSitePluginInfo() + ":CategorySummaryDocumentRenderer");
+                    siteDirectory,
+                    subMojoExecution.getGoal(),
+                    subMojoExecution.getPlugin().getId() + ':' + subMojoExecution.getGoal());
             String title = i18n.getString("site-plugin", locale, "report.project.title");
             String desc1 = i18n.getString("site-plugin", locale, "report.project.description1");
             String desc2 = i18n.getString("site-plugin", locale, "report.project.description2");
             DocumentRenderer docRenderer = new CategorySummaryDocumentRenderer(
-                    docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());
+                    subMojoExecution, docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());
 
             String filename = docRenderer.getOutputName();
             if (!documents.containsKey(filename)) {
@@ -452,12 +458,6 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
         return documents;
     }
 
-    private String getSitePluginInfo() {
-        PluginDescriptor pluginDescriptor =
-                (PluginDescriptor) getPluginContext().get("pluginDescriptor");
-        return pluginDescriptor.getId();
-    }
-
     protected void populateReportItems(
             SiteModel siteModel, Locale locale, Map<String, MavenReport> reportsByOutputName) {
         for (Menu menu : siteModel.getMenus()) {
diff --git a/src/main/java/org/apache/maven/plugins/site/render/CategorySummaryDocumentRenderer.java b/src/main/java/org/apache/maven/plugins/site/render/CategorySummaryDocumentRenderer.java
index b9080ffa..c9277c6b 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/CategorySummaryDocumentRenderer.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/CategorySummaryDocumentRenderer.java
@@ -24,12 +24,12 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 
-import org.apache.maven.doxia.siterenderer.DocumentRenderer;
 import org.apache.maven.doxia.siterenderer.DocumentRenderingContext;
 import org.apache.maven.doxia.siterenderer.RendererException;
 import org.apache.maven.doxia.siterenderer.SiteRenderer;
 import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
+import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.reporting.MavenReport;
 import org.codehaus.plexus.i18n.I18N;
@@ -39,9 +39,11 @@ import org.codehaus.plexus.i18n.I18N;
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
-public class CategorySummaryDocumentRenderer implements DocumentRenderer {
+public class CategorySummaryDocumentRenderer implements SitePluginReportDocumentRenderer {
     private DocumentRenderingContext docRenderingContext;
 
+    private final String reportMojoInfo;
+
     private String title;
 
     private String desc1;
@@ -55,16 +57,7 @@ public class CategorySummaryDocumentRenderer implements DocumentRenderer {
     private final Log log;
 
     public CategorySummaryDocumentRenderer(
-            DocumentRenderingContext docRenderingContext,
-            String title,
-            String desc1,
-            String desc2,
-            I18N i18n,
-            List<MavenReport> categoryReports) {
-        this(docRenderingContext, title, desc1, desc2, i18n, categoryReports, null);
-    }
-
-    public CategorySummaryDocumentRenderer(
+            MojoExecution mojoExecution,
             DocumentRenderingContext docRenderingContext,
             String title,
             String desc1,
@@ -73,6 +66,11 @@ public class CategorySummaryDocumentRenderer implements DocumentRenderer {
             List<MavenReport> categoryReports,
             Log log) {
         this.docRenderingContext = docRenderingContext;
+        this.reportMojoInfo = mojoExecution.getPlugin().getArtifactId()
+                + ':'
+                + mojoExecution.getPlugin().getVersion()
+                + ':'
+                + mojoExecution.getGoal();
         this.title = title;
         this.desc1 = desc1;
         this.desc2 = desc2;
@@ -186,4 +184,9 @@ public class CategorySummaryDocumentRenderer implements DocumentRenderer {
     public boolean isExternalReport() {
         return false;
     }
+
+    @Override
+    public String getReportMojoInfo() {
+        return reportMojoInfo;
+    }
 }