protected Map locateDocuments()

in src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java [434:520]


    protected Map<String, DocumentRenderer> locateDocuments(
            SiteRenderingContext context, List<MavenReportExecution> reports, Locale locale)
            throws IOException, RendererException {
        Map<String, DocumentRenderer> documents = siteRenderer.locateDocumentFiles(context);

        Map<String, MavenReport> reportsByOutputName = locateReports(reports, documents, locale);

        // TODO: I want to get rid of categories eventually. There's no way to add your own in a fully i18n manner
        Map<String, List<MavenReport>> categories = categoriseReports(reportsByOutputName.values());

        siteTool.populateReportsMenu(context.getSiteModel(), locale, categories);
        populateReportItems(context.getSiteModel(), locale, reportsByOutputName);

        File localizedSiteDirectory;
        if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
            localizedSiteDirectory = new File(siteDirectory, locale.toString());
        } else {
            localizedSiteDirectory = siteDirectory;
        }

        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(
                    localizedSiteDirectory,
                    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(
                    subMojoExecution, docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());

            String filename = docRenderer.getOutputName();
            if (!documents.containsKey(filename)) {
                documents.put(filename, docRenderer);
            } else {
                getLog().info("Skipped \"" + title + "\" report; file \"" + filename + "\" already exists.");
            }
        }

        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(
                    localizedSiteDirectory,
                    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(
                    subMojoExecution, docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());

            String filename = docRenderer.getOutputName();
            if (!documents.containsKey(filename)) {
                documents.put(filename, docRenderer);
            } else {
                getLog().info("Skipped \"" + title + "\" report; file \"" + filename + "\" already exists.");
            }
        }

        if (generateSitemap) {
            MojoExecution subMojoExecution =
                    new MojoExecution(mojoExecution.getPlugin(), "sitemap", mojoExecution.getExecutionId());
            DocumentRenderingContext docRenderingContext = new DocumentRenderingContext(
                    localizedSiteDirectory,
                    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;
    }