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);
}
}
}
Aggregations