Skip to content

Latest commit

 

History

History
75 lines (68 loc) · 13.2 KB

readme.md

File metadata and controls

75 lines (68 loc) · 13.2 KB

The Avro maven plugin

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.avro</groupId>
        <artifactId>avro-maven-plugin</artifactId>
        <version>${avro.version}</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>schema</goal>
              <goal>protocol</goal>
              <goal>idl-protocol</goal>
            </goals>
            <configuration>
              <fieldVisibility>public</fieldVisibility>
              <stringType>String</stringType>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

SpecificCompiler options

avro-tools Plugin SpecificCompiler properties and accessors Description
x customConversions = new String[0] specificData
sc.addLogicalTypeConversions(SpecificData)
sc.addCustomConversion(Class<?>)
sc.getUsedConversionClasses()
x customLogicalTypeFactories = new String[0] LogicalTypes.register(...)
x x queue
x x protocol
x x velocityEngine
x velocityToolsClassesNames = new String[0] additionalVelocityTools
sc.setAdditionalVelocityTools(List<Object>)
Puts instances of any object into the velocity context (references by their simple class name).
x templateDirectory = "/org/apache/avro/compiler/specific/templates/java/classic/" templateDir = "/org/apache/avro/compiler/specific/templates/java/classic/"
(Overridden by org.apache.avro.specific.templates)
sc.setTemplateDir(String)
Where to find the velocity templates.
[-fieldVisibility <visibilityType>] fieldVisibility = private fieldVisibility = PRIVATE
sc.setFieldVisibility(FieldVisibility)
sc.deprecatedFields()
sc.publicFields()
sc.privateFields()
Record fields should be public @Deprecated public, or private
x createSetters = true **createSetters = true****
sc.isCreateSetters()
sc.setCreateSetters(boolean)
Whether to create setters for fields of the record.
x createOptionalGetters = false **createOptionalGetters = false****
sc.isCreateOptionalGetters()
sc.setCreateOptionalGetters(boolean)
Whether to create additional getters getOptionalMyField() for fields of the record.
x gettersReturnOptional = false gettersReturnOptional = false
sc.isGettersReturnOptional()
sc.setGettersReturnOptional(boolean)
Whether the getters return Optional<...> instead of possibly null.
x optionalGettersForNullableFieldsOnly = false optionalGettersForNullableFieldsOnly = false
sc.isOptionalGettersForNullableFieldsOnly()
sc.setOptionalGettersForNullableFieldsOnly(boolean)
If gettersReturnOptional, only if they are actually nullable.
x enableDecimalLogicalType = false enableDecimalLogicalType = false
sc.setEnableDecimalLogicalType()
Whether to create setters for fields of the record.
x x createAllArgsConstructor = true
sc.isCreateAllArgsConstructor
If possible, create a constructor with every field.
[-encoding <outputencoding>] x outputCharacterEncoding
sc.setOutputCharacterEncoding(String)
[-bigDecimal] x enableDecimalLogicalType
sc.setEnableDecimalLogicalType
Whether to use the Decimal type
x x suffix = .java
sc.setSuffix(String)
-string to use String, else CharSequence stringType = "CharSequence" stringType = CharSequence
setStringType(StringType)
One of CharSequence, String, Utf8
input sourceDirectory = "${basedir}/src/main/avro"
outputdir outputDirectory = "${project.build.directory}/generated-sources/avro"
x testSourceDirectory = "${basedir}/src/main/avro"
x testOutputDirectory = "${project.build.directory}/generated-sources/avro"
x imports
x excludes = new String[0]
x testExcludes = new String[0]
x includes = new String[] { "**/*.avsc" } SchemaMojo (.avpr for ProtocolMojo)
x testIncludes = new String[] { "**/*.avsc" } SchemaMojo (.avpr for ProtocolMojo)

TODO

  • Add AVRO-2937 to this list.

  • Apply a same order

  • Align the documentation and defaults

  • Maven plugin defaults sometimes in parameter sometimes set?

  • Maven plugin testSourceDirectory have property set to sourceDirectory

  • " -string - use java.lang.String instead of Utf8" is wrong ?