* written.
*/
protected void processTemplate( String templateName, File targetDirectory )
throws MojoFailureException
{
FileWriterWithEncoding pageWriter = null;
try
{
pageWriter =
new FileWriterWithEncoding( new File( targetDirectory.getCanonicalPath() + File.separator
+ templateName ), Charset.forName( outputEncoding ) );
velocityEngine.mergeTemplate( "/templates/source-view/" + templateName + ".vm",
Charset.forName( "UTF-8" ).name(), velocityContext, pageWriter );
}
catch ( ResourceNotFoundException e )
{
throw new MojoFailureException( "The template '" + templateName + "' could not be found.", e );
}
catch ( ParseErrorException e )
{
throw new MojoFailureException( "Failed to parse the template '" + templateName + "' .", e );
}
catch ( Exception e )
{
throw new MojoFailureException( "Failed to load the template '" + templateName + "' .", e );
}
finally
{
try
{
pageWriter.close();
}
catch ( IOException e )
{
throw new MojoFailureException( "Failed to write the template '" + templateName + "' .", e );
}