Class ModelloVelocityMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.modello.maven.AbstractModelloGeneratorMojo
org.codehaus.modello.maven.ModelloVelocityMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="velocity", defaultPhase=GENERATE_SOURCES, threadSafe=true) public class ModelloVelocityMojo extends AbstractModelloGeneratorMojo
Creates files from the model using Velocity templates.

This mojo can be given a list of templates and a list of parameters. Each template from the templates property will be run with the following context:

  • version: the version of the model to generate
  • model: the modello model
  • Helper: a Helper object instance
  • any additional parameters specified using the params property
The output file is controlled from within the template using the #MODELLO-VELOCITY#SAVE-OUTPUT-TO VTL directive. This allows a single template to generate multiple files. For example, the following directive will redirect further output from the template to a file named org/apache/maven/api/model/Plugin.java if the variable package is set to org.apache.maven.api.model and the variable className is set to Plugin.

#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java

  • Field Details

    • outputDirectory

      @Parameter(defaultValue="${project.build.directory}/generated-sources/modello") private File outputDirectory
      The output directory of the generated files.
    • velocityBasedir

      @Parameter(defaultValue="${project.basedir}") private File velocityBasedir
      The directory where Velocity templates are looked for.
    • templates

      @Parameter private List<String> templates
      A list of template paths to be run against the loaded Modello model. Those are .vm files as described in the Velocity Users Guide relative to velocityBasedir.
    • params

      @Parameter private List<String> params
      A list of parameters, using the syntax key=value. Those parameters will be made accessible to the templates.
  • Constructor Details

    • ModelloVelocityMojo

      public ModelloVelocityMojo()
  • Method Details