Search in sources :

Example 1 with ToolManager

use of org.apache.velocity.tools.ToolManager in project maven-plugins by apache.

the class AnnouncementMojo method doGenerate.

protected void doGenerate(List<Release> releases, Release release) throws MojoExecutionException {
    try {
        ToolManager toolManager = new ToolManager(true);
        Context context = toolManager.createContext();
        if (getIntroduction() == null || getIntroduction().equals("")) {
            setIntroduction(getUrl());
        }
        context.put("releases", releases);
        context.put("groupId", getGroupId());
        context.put("artifactId", getArtifactId());
        context.put("version", getVersion());
        context.put("packaging", getPackaging());
        context.put("url", getUrl());
        context.put("release", release);
        context.put("introduction", getIntroduction());
        context.put("developmentTeam", getDevelopmentTeam());
        context.put("finalName", getFinalName());
        context.put("urlDownload", getUrlDownload());
        context.put("project", project);
        if (announceParameters == null) {
            // empty Map to prevent NPE in velocity execution
            context.put("announceParameters", Collections.emptyMap());
        } else {
            context.put("announceParameters", announceParameters);
        }
        processTemplate(context, announcementDirectory, template, announcementFile);
    } catch (ResourceNotFoundException rnfe) {
        throw new MojoExecutionException("Resource not found.", rnfe);
    } catch (VelocityException ve) {
        throw new MojoExecutionException(ve.toString(), ve);
    }
}
Also used : Context(org.apache.velocity.context.Context) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) VelocityException(org.apache.velocity.exception.VelocityException) ToolManager(org.apache.velocity.tools.ToolManager) ResourceNotFoundException(org.apache.velocity.exception.ResourceNotFoundException)

Aggregations

MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 Context (org.apache.velocity.context.Context)1 ResourceNotFoundException (org.apache.velocity.exception.ResourceNotFoundException)1 VelocityException (org.apache.velocity.exception.VelocityException)1 ToolManager (org.apache.velocity.tools.ToolManager)1