Apache MyFaces
Project Documentation
Foundation

myfaces-builder:make-components

Maven goal to generate java source code for Component classes.

It uses velocity to generate templates, and has the option to define custom templates.

The executed template has the following variables available to it:

  • utils : Returns an instance of org.apache.myfaces.buildtools.maven2.plugin.builder.utils.MyfacesUtils, it contains some useful methods.
  • component : Returns the current instance of org.apache.myfaces.buildtools.maven2.plugin.builder.model.ComponentMeta
  • innersource : code to be injected from the template class when template mode is used

Mojo Attributes:

  • Requires a Maven 2.0 project to execute.
  • Requires dependency resolution of artifacts in scope: compile
  • Automatically executes within the lifecycle phase: generate-sources

Optional Parameters

Name Type Description
buildDirectory File Defines the directory where the metadata file (META-INF/myfaces-metadata.xml) is loaded.
force boolean Log and continue execution when generating component classes.

If this property is set to false (default), errors when a component class is generated stops execution immediately.

generatedSourceDirectory File The directory where all generated files are created. This directory is added as a compile source root automatically like src/main/java is.
jsfVersion String Defines the jsf version (1.1 or 1.2), used to take the default templates for each version.

If version is 1.1, the default templateComponentName is 'componentClass11.vm', if version is 1.2 the default templateComponentName is 'componentClass12.vm', if version is 2.0 the default templateComponentName is 'componentClass20.vm'

mainSourceDirectory File This param is used to search in this folder if some file to be generated exists and avoid generation and duplicate exception.
mainSourceDirectory2 File This param is used to search in this folder if some file to be generated exists and avoid generation and duplicate exception.
metadataFile String Injected name of file generated by earlier run of BuildMetaDataMojo goal.
modelIds List Define the models that should be included when generate component classes. If not set, the current model identified by the artifactId is used.

Each model built by build-metadata goal has a modelId, that by default is the artifactId of the project. Setting this property defines which objects tied in a specified modelId should be taken into account.

In this case, limit component generation only to the components defined in the models identified by the modelId defined.

This is useful when you need to generate files that take information defined on other projects

Example:

<modelIds>
<modelId>model1</modelId>
<modelId>model2</modelId>
</modelIds>
packageContains String Generate only component classes that starts with the specified package prefix.
templateComponentName String The name of the template used to generate component classes. According to the value on jsfVersion property the default if this property is not set could be componentClass11.vm (1.1) or componentClass12.vm (1.2)
templateSourceDirectory File The directory used to load templates into velocity environment.
typePrefix String Generate only component classes that starts with the specified component type prefix.

Parameter Details

buildDirectory

Defines the directory where the metadata file (META-INF/myfaces-metadata.xml) is loaded.

  • Type: java.io.File
  • Required: No
  • Expression: ${project.build.directory}/generated-resources/myfaces-builder-plugin

force

Log and continue execution when generating component classes.

If this property is set to false (default), errors when a component class is generated stops execution immediately.

  • Type: boolean
  • Required: No

generatedSourceDirectory

The directory where all generated files are created. This directory is added as a compile source root automatically like src/main/java is.

  • Type: java.io.File
  • Required: No
  • Expression: ${project.build.directory}/generated-sources/myfaces-builder-plugin

jsfVersion

Defines the jsf version (1.1 or 1.2), used to take the default templates for each version.

If version is 1.1, the default templateComponentName is 'componentClass11.vm', if version is 1.2 the default templateComponentName is 'componentClass12.vm', if version is 2.0 the default templateComponentName is 'componentClass20.vm'

  • Type: java.lang.String
  • Required: No

mainSourceDirectory

This param is used to search in this folder if some file to be generated exists and avoid generation and duplicate exception.

  • Type: java.io.File
  • Required: No
  • Expression: src/main/java

mainSourceDirectory2

This param is used to search in this folder if some file to be generated exists and avoid generation and duplicate exception.

  • Type: java.io.File
  • Required: No

metadataFile

Injected name of file generated by earlier run of BuildMetaDataMojo goal.

  • Type: java.lang.String
  • Required: No

modelIds

Define the models that should be included when generate component classes. If not set, the current model identified by the artifactId is used.

Each model built by build-metadata goal has a modelId, that by default is the artifactId of the project. Setting this property defines which objects tied in a specified modelId should be taken into account.

In this case, limit component generation only to the components defined in the models identified by the modelId defined.

This is useful when you need to generate files that take information defined on other projects

Example:

<modelIds>
<modelId>model1</modelId>
<modelId>model2</modelId>
</modelIds>
  • Type: java.util.List
  • Required: No

packageContains

Generate only component classes that starts with the specified package prefix.

  • Type: java.lang.String
  • Required: No

templateComponentName

The name of the template used to generate component classes. According to the value on jsfVersion property the default if this property is not set could be componentClass11.vm (1.1) or componentClass12.vm (1.2)

  • Type: java.lang.String
  • Required: No

templateSourceDirectory

The directory used to load templates into velocity environment.

  • Type: java.io.File
  • Required: No
  • Expression: src/main/resources/META-INF

typePrefix

Generate only component classes that starts with the specified component type prefix.

  • Type: java.lang.String
  • Required: No