Search in sources :

Example 1 with DocumentRendererContext

use of org.apache.maven.doxia.docrenderer.DocumentRendererContext in project maven-plugins by apache.

the class PdfMojo method generatePdf.

/**
     * Generate the PDF.
     *
     * @throws MojoExecutionException if any
     * @throws IOException if any
     * @since 1.1
     */
private void generatePdf() throws MojoExecutionException, IOException {
    Locale.setDefault(getDefaultLocale());
    for (final Locale locale : getAvailableLocales()) {
        final File workingDir = getLocaleDirectory(workingDirectory, locale);
        File siteDirectoryFile = getLocaleDirectory(getSiteDirectoryTmp(), locale);
        copyResources(locale);
        generateMavenReports(locale);
        DocumentRendererContext context = new DocumentRendererContext();
        context.put("project", project);
        context.put("settings", settings);
        context.put("PathTool", new PathTool());
        context.put("FileUtils", new FileUtils());
        context.put("StringUtils", new StringUtils());
        context.put("i18n", i18n);
        context.put("generateTOC", generateTOC);
        context.put("validate", validate);
        // Put any of the properties in directly into the Velocity context
        for (Map.Entry<Object, Object> entry : project.getProperties().entrySet()) {
            context.put((String) entry.getKey(), entry.getValue());
        }
        final DocumentModel model = aggregate ? getDocumentModel(locale) : null;
        try {
            // TODO use interface see DOXIASITETOOLS-30
            ((AbstractDocumentRenderer) docRenderer).render(siteDirectoryFile, workingDir, model, context);
        } catch (DocumentRendererException e) {
            throw new MojoExecutionException("Error during document generation: " + e.getMessage(), e);
        }
    }
}
Also used : Locale(java.util.Locale) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DocumentRendererContext(org.apache.maven.doxia.docrenderer.DocumentRendererContext) FileUtils(org.codehaus.plexus.util.FileUtils) DocumentRendererException(org.apache.maven.doxia.docrenderer.DocumentRendererException) DocumentModel(org.apache.maven.doxia.document.DocumentModel) PathTool(org.codehaus.plexus.util.PathTool) StringUtils(org.codehaus.plexus.util.StringUtils) AbstractDocumentRenderer(org.apache.maven.doxia.docrenderer.AbstractDocumentRenderer) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 AbstractDocumentRenderer (org.apache.maven.doxia.docrenderer.AbstractDocumentRenderer)1 DocumentRendererContext (org.apache.maven.doxia.docrenderer.DocumentRendererContext)1 DocumentRendererException (org.apache.maven.doxia.docrenderer.DocumentRendererException)1 DocumentModel (org.apache.maven.doxia.document.DocumentModel)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 FileUtils (org.codehaus.plexus.util.FileUtils)1 PathTool (org.codehaus.plexus.util.PathTool)1 StringUtils (org.codehaus.plexus.util.StringUtils)1