public void generate ( String outputFilename , String template , Context context ) throws VelocityException , MojoExecutionException , IOException { Writer writer = null ; try { File f = new File ( outputFilename ) ; if ( ! f . getParentFile ( ) . exists ( ) ) { f . getParentFile ( ) . mkdirs ( ) ; } writer = new FileWriter ( f ) ; getVelocity ( ) . getEngine ( ) . mergeTemplate ( templateDirectory + "/" + template , context , writer ) ; } catch ( ResourceNotFoundException e ) { throw new ResourceNotFoundException ( "Template not found: " + templateDirectory + "/" + template , e ) ; } catch ( VelocityException | IOException e ) { throw e ; // to get past generic catch for Exception. } catch ( Exception e ) { throw new MojoExecutionException ( e . getMessage ( ) , e ) ; } finally { if ( writer != null ) { writer . flush ( ) ; writer . close ( ) ; getLog ( ) . debug ( "File " + outputFilename + " created..." ) ; } } }
Using a specified Velocity Template and provided context create the outputFilename .