protected SiteRenderingContext createSiteRenderingContext()

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


    protected SiteRenderingContext createSiteRenderingContext(Locale locale)
            throws MojoExecutionException, IOException, MojoFailureException {
        SiteModel siteModel = prepareSiteModel(locale);
        Map<String, Object> templateProperties = new HashMap<>();
        templateProperties.put("project", project);
        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 : project.getProperties().entrySet()) {
            templateProperties.put((String) entry.getKey(), entry.getValue());
        }

        // Comes last if someone wants to deliberately override any default or model properties
        if (attributes != null) {
            templateProperties.putAll(attributes);
        }

        SiteRenderingContext context;
        try {
            Artifact skinArtifact =
                    siteTool.getSkinArtifactFromRepository(repoSession, remoteProjectRepositories, siteModel.getSkin());

            getLog().info(buffer().a("Rendering content with ")
                    .strong(skinArtifact.getId() + " skin")
                    .build());

            context = siteRenderer.createContextForSkin(
                    skinArtifact, templateProperties, siteModel, project.getName(), locale);
        } catch (SiteToolException e) {
            throw new MojoExecutionException("Failed to retrieve skin artifact from repository", e);
        } catch (RendererException e) {
            throw new MojoExecutionException("Failed to create context for skin", e);
        }

        // Add publish date
        MavenArchiver.parseBuildOutputTimestamp(outputTimestamp).ifPresent(v -> {
            context.setPublishDate(Date.from(v));
        });

        // Generate static site
        context.setRootDirectory(project.getBasedir());
        if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
            context.addSiteDirectory(new SiteDirectory(new File(siteDirectory, locale.toString()), true));
            context.addSiteDirectory(new SiteDirectory(new File(generatedSiteDirectory, locale.toString()), false));
        } else {
            context.addSiteDirectory(new SiteDirectory(siteDirectory, true));
            context.addSiteDirectory(new SiteDirectory(generatedSiteDirectory, false));
        }

        if (moduleExcludes != null) {
            context.setModuleExcludes(moduleExcludes);
        }

        if (saveProcessedContent) {
            File processedDir = new File(generatedSiteDirectory, "processed");
            if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
                context.setProcessedContentOutput(new File(processedDir, locale.toString()));
            } else {
                context.setProcessedContentOutput(processedDir);
            }
        }

        return context;
    }