org.apache.avro.mojo

## Class AbstractAvroMojo

- java.lang.Object
- - org.apache.maven.plugin.AbstractMojo
  - - org.apache.avro.mojo.AbstractAvroMojo

All Implemented Interfaces:
  org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

Direct Known Subclasses:
  IDLProtocolMojo, ProtocolMojo, SchemaMojo

    public abstract class AbstractAvroMojo
    extends org.apache.maven.plugin.AbstractMojo

Base for Avro Compiler Mojos.

### Field Summary

Fields
`protected boolean` `createOptionalGetters` The createOptionalGetters parameter enables generating the getOptional...
`protected boolean` `createSetters` Determines whether or not to create setters for the fields of the record.
`protected String[]` `customConversions` A set of fully qualified class names of custom `Conversion` implementations to add to the compiler.
`protected String[]` `customLogicalTypeFactories` A set of fully qualified class names of custom `LogicalTypes.LogicalTypeFactory` implementations to add to the compiler.
`protected boolean` `enableDecimalLogicalType` Determines whether or not to use Java classes for decimal types
`protected String[]` `excludes` A set of Ant-like exclusion patterns used to prevent certain files from being processed.
`protected boolean` `gettersReturnOptional` The gettersReturnOptional parameter enables generating get...
`protected String[]` `imports` A list of files or directories that should be compiled first thus making them importable by subsequently compiled schemas.
`protected boolean` `optionalGettersForNullableFieldsOnly` The optionalGettersForNullableFieldsOnly parameter works in conjunction with gettersReturnOptional option.
`protected org.apache.maven.project.MavenProject` `project` The current Maven project.
`protected String` `stringType` The Java type to use for Avro strings.
`protected String` `templateDirectory` The directory (within the java classpath) that contains the velocity templates to use for code generation.
`protected String[]` `testExcludes` A set of Ant-like exclusion patterns used to prevent certain files from being processed.
`protected String[]` `velocityToolsClassesNames` The qualified names of classes which the plugin will look up, instantiate (through an empty constructor that must exist) and set up to be injected into Velocity templates by Avro compiler.

### Fields inherited from interface org.apache.maven.plugin.Mojo

`ROLE`

### Constructor Summary

Constructors
Constructor and Description
`AbstractAvroMojo()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected URLClassLoader` `createClassLoader()`
`protected abstract void` `doCompile(String filename, File sourceDirectory, File outputDirectory)`
`void` `execute()`
`protected org.apache.avro.compiler.specific.SpecificCompiler.FieldVisibility` `getFieldVisibility()`
`protected abstract String[]` `getIncludes()`
`protected abstract String[]` `getTestIncludes()`
`protected List<Object>` `instantiateAdditionalVelocityTools()`

### Methods inherited from class org.apache.maven.plugin.AbstractMojo

`getLog, getPluginContext, setLog, setPluginContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### imports

    protected String[] imports

A list of files or directories that should be compiled first thus making them importable by subsequently compiled schemas. Note that imported files should not reference each other.

Is defined by:

#### excludes

    protected String[] excludes

A set of Ant-like exclusion patterns used to prevent certain files from being processed. By default, this set is empty such that no files are excluded.

Is defined by:

#### testExcludes

    protected String[] testExcludes

A set of Ant-like exclusion patterns used to prevent certain files from being processed. By default, this set is empty such that no files are excluded.

Is defined by:

#### stringType

    protected String stringType

The Java type to use for Avro strings. May be one of CharSequence, String or Utf8. CharSequence by default.

Is defined by:
  property:
    stringType

#### templateDirectory

    protected String templateDirectory

The directory (within the java classpath) that contains the velocity templates to use for code generation. The default value points to the templates included with the avro-maven-plugin.

Is defined by:
  property:
    templateDirectory

#### velocityToolsClassesNames

    protected String[] velocityToolsClassesNames

The qualified names of classes which the plugin will look up, instantiate (through an empty constructor that must exist) and set up to be injected into Velocity templates by Avro compiler.

Is defined by:
  property:
    velocityToolsClassesNames

#### createOptionalGetters

    protected boolean createOptionalGetters

The createOptionalGetters parameter enables generating the getOptional... methods that return an Optional of the requested type. This works ONLY on Java 8+

Is defined by:
  property:
    createOptionalGetters

#### gettersReturnOptional

    protected boolean gettersReturnOptional

The gettersReturnOptional parameter enables generating get... methods that return an Optional of the requested type. This works ONLY on Java 8+

Is defined by:
  property:
    gettersReturnOptional

#### optionalGettersForNullableFieldsOnly

    protected boolean optionalGettersForNullableFieldsOnly

The optionalGettersForNullableFieldsOnly parameter works in conjunction with gettersReturnOptional option. If it is set, Optional getters will be generated only for fields that are nullable. If the field is mandatory, regular getter will be generated. This works ONLY on Java 8+.

Is defined by:
  property:
    optionalGettersForNullableFieldsOnly

#### createSetters

    protected boolean createSetters

Determines whether or not to create setters for the fields of the record. The default is to create setters.

Is defined by:
  default-value:
    true

#### customConversions

    protected String[] customConversions

A set of fully qualified class names of custom `Conversion` implementations to add to the compiler. The classes must be on the classpath at compile time and whenever the Java objects are serialized.

Is defined by:
  property:
    customConversions

#### customLogicalTypeFactories

    protected String[] customLogicalTypeFactories

A set of fully qualified class names of custom `LogicalTypes.LogicalTypeFactory` implementations to add to the compiler. The classes must be on the classpath at compile time and whenever the Java objects are serialized.

Is defined by:
  property:
    customLogicalTypeFactories

#### enableDecimalLogicalType

    protected boolean enableDecimalLogicalType

Determines whether or not to use Java classes for decimal types

Is defined by:
  default-value:
    false

#### project

    protected org.apache.maven.project.MavenProject project

The current Maven project.

Is readonly.
Is defined by:
  default-value:
    ${project}
Is required.

### Constructor Detail

#### AbstractAvroMojo

    public AbstractAvroMojo()

### Method Detail

#### execute

    public void execute()
                 throws org.apache.maven.plugin.MojoExecutionException

Throws:
  `org.apache.maven.plugin.MojoExecutionException`

#### getFieldVisibility

    protected org.apache.avro.compiler.specific.SpecificCompiler.FieldVisibility getFieldVisibility()

#### instantiateAdditionalVelocityTools

    protected List<Object> instantiateAdditionalVelocityTools()

#### doCompile

    protected abstract void doCompile(String filename,
                                      File sourceDirectory,
                                      File outputDirectory)
                               throws IOException

Throws:
  `IOException`

#### createClassLoader

    protected URLClassLoader createClassLoader()
                                        throws org.apache.maven.artifact.DependencyResolutionRequiredException,
                                               MalformedURLException

Throws:
  `org.apache.maven.artifact.DependencyResolutionRequiredException`
  `MalformedURLException`

#### getIncludes

    protected abstract String[] getIncludes()

#### getTestIncludes

    protected abstract String[] getTestIncludes()