Package org.codehaus.modello.maven
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 AbstractModelloGeneratorMojoCreates 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
templatesproperty will be run with the following context:version: the version of the model to generatemodel: the modello modelHelper: aHelperobject instance- any additional parameters specified using the
paramsproperty
#MODELLO-VELOCITY#SAVE-OUTPUT-TOVTL 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 namedorg/apache/maven/api/model/Plugin.javaif the variablepackageis set toorg.apache.maven.api.modeland the variableclassNameis set toPlugin.#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FileoutputDirectoryThe output directory of the generated files.private java.util.List<java.lang.String>paramsA list of parameters, using the syntaxkey=value.private java.util.List<java.lang.String>templatesA list of template paths to be run against the loaded Modello model.private java.io.FilevelocityBasedirThe directory where Velocity templates are looked for.
-
Constructor Summary
Constructors Constructor Description ModelloVelocityMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcustomizeParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)Override this method to customize the values in the properties set.protected java.lang.StringgetGeneratorType()java.io.FilegetOutputDirectory()protected booleanproducesCompilableResult()-
Methods inherited from class org.codehaus.modello.maven.AbstractModelloGeneratorMojo
createParameters, execute, getBasedir, getModelloCore, getModels, getPackageWithVersion, getProject, getVersion, producesResources, setBasedir, setBuildContext, setModelloCore, setModels, setPackagedVersions, setPackageWithVersion, setProject, setVersion
-
-
-
-
Field Detail
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}/generated-sources/modello") private java.io.File outputDirectoryThe output directory of the generated files.
-
velocityBasedir
@Parameter(defaultValue="${project.basedir}") private java.io.File velocityBasedirThe directory where Velocity templates are looked for.
-
templates
@Parameter private java.util.List<java.lang.String> templates
A list of template paths to be run against the loaded Modello model. Those are.vmfiles as described in the Velocity Users Guide relative tovelocityBasedir.
-
params
@Parameter private java.util.List<java.lang.String> params
A list of parameters, using the syntaxkey=value. Those parameters will be made accessible to the templates.
-
-
Method Detail
-
getGeneratorType
protected java.lang.String getGeneratorType()
- Specified by:
getGeneratorTypein classAbstractModelloGeneratorMojo
-
customizeParameters
protected void customizeParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
Description copied from class:AbstractModelloGeneratorMojoOverride this method to customize the values in the properties set.This method will be called after the parameters have been populated with the parameters in the abstract mojo.
- Overrides:
customizeParametersin classAbstractModelloGeneratorMojo- Parameters:
parameters- the parameters to customize
-
producesCompilableResult
protected boolean producesCompilableResult()
- Overrides:
producesCompilableResultin classAbstractModelloGeneratorMojo
-
getOutputDirectory
public java.io.File getOutputDirectory()
- Specified by:
getOutputDirectoryin classAbstractModelloGeneratorMojo
-
-