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/18 09:26:41 UTC
[maven-site-plugin] 06/10: [MSITE-953] Log statistics about rendered non-Doxia documents
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 1ed9c2f48b4a657896594071718e275c2de006ae
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 | 58 ++++++++++++++++++++--
1 file changed, 55 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..41c81b92 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,58 @@ 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) {
+ type = "report";
+ } else if (doc instanceof SitePluginReportDocumentRenderer) {
+ type = "site-plugin-report";
+ } else {
+ type = "other";
+ }
+
+ Integer count = counts.get(type);
+ if (count == null) {
+ count = 1;
+ } else {
+ count++;
+ }
+ counts.put(type, count);
+ }
+
+ if (documents.size() > 0) {
+ MessageBuilder mb = buffer();
+ mb.a("Rendering ");
+ mb.strong(documents.size() + " non-Doxia document" + (documents.size() > 1 ? "s" : ""));
+ mb.a(": ");
+
+ boolean first = true;
+ for (Map.Entry<String, Integer> entry : counts.entrySet()) {
+ if (first) {
+ first = false;
+ } else {
+ mb.a(", ");
+ }
+ String type = entry.getKey();
+ Integer count = entry.getValue();
+ mb.strong(count + " " + type + (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)) {