Search in sources :

Example 1 with StringUtils

use of org.codehaus.plexus.util.StringUtils in project maven-plugins by apache.

the class DefaultCheckstyleRssGenerator method generateRSS.

@Override
public void generateRSS(CheckstyleResults results, CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest) throws MavenReportException {
    VelocityTemplate vtemplate = new VelocityTemplate(velocityComponent, CheckstyleReport.PLUGIN_RESOURCES);
    vtemplate.setLog(checkstyleRssGeneratorRequest.getLog());
    Context context = new VelocityContext();
    context.put("results", results);
    context.put("project", checkstyleRssGeneratorRequest.getMavenProject());
    context.put("copyright", checkstyleRssGeneratorRequest.getCopyright());
    context.put("levelInfo", SeverityLevel.INFO);
    context.put("levelWarning", SeverityLevel.WARNING);
    context.put("levelError", SeverityLevel.ERROR);
    context.put("stringutils", new StringUtils());
    try {
        vtemplate.generate(checkstyleRssGeneratorRequest.getOutputDirectory().getPath() + "/checkstyle.rss", "checkstyle-rss.vm", context);
    } catch (ResourceNotFoundException e) {
        throw new MavenReportException("Unable to find checkstyle-rss.vm resource.", e);
    } catch (MojoExecutionException | IOException | VelocityException e) {
        throw new MavenReportException("Unable to generate checkstyle.rss.", e);
    }
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) Context(org.apache.velocity.context.Context) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) VelocityContext(org.apache.velocity.VelocityContext) StringUtils(org.codehaus.plexus.util.StringUtils) VelocityException(org.apache.velocity.exception.VelocityException) IOException(java.io.IOException) ResourceNotFoundException(org.apache.velocity.exception.ResourceNotFoundException) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 2 with StringUtils

use of org.codehaus.plexus.util.StringUtils 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

MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 StringUtils (org.codehaus.plexus.util.StringUtils)2 File (java.io.File)1 IOException (java.io.IOException)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 MavenReportException (org.apache.maven.reporting.MavenReportException)1 VelocityContext (org.apache.velocity.VelocityContext)1 Context (org.apache.velocity.context.Context)1 ResourceNotFoundException (org.apache.velocity.exception.ResourceNotFoundException)1 VelocityException (org.apache.velocity.exception.VelocityException)1 FileUtils (org.codehaus.plexus.util.FileUtils)1 PathTool (org.codehaus.plexus.util.PathTool)1