relateiq/avrohugger-maven-plugin

Name: avrohugger-maven-plugin

Owner: SalesforceIQ

Description: Maven plugin for generating Scala case classes and ADTs from Apache Avro schemas, datafiles, and protocols

Created: 2017-10-24 17:45:05.0

Updated: 2017-10-24 17:45:07.0

Pushed: 2017-10-24 23:31:31.0

Homepage:

Size: 89

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Avrohugger Maven Plugin

Maven plugin for generating Scala case classes and ADTs from Apache Avro schemas, datafiles, and protocols.

Build Status Maven Central Join the chat at https://gitter.im/julianpeeters/avrohugger

Attention Attention: artifactId changed

Please be aware that the artifactId changed from avrohugger-maven-plugin_2.11 to avrohugger-maven-plugin.

There is no reason to cross-compile Maven plugins, see http://maven.apache.org/guides/mini/guide-maven-classloading.html#Plugin_Classloaders.

Usage

The plugin currently supports one goal:

gin>
<groupId>at.makubi.maven.plugin</groupId>
<artifactId>avrohugger-maven-plugin</artifactId>
<version>1.4</version>
<executions>
    <execution>
        <phase>generate-sources</phase>
        <goals>
            <goal>generate-scala-sources</goal>
        </goals>
    </execution>
</executions>
ugin>
Usage in conjunction with the scala-maven-plugin

This plugin can be used in conjunction with the scala-maven-plugin to add the generated Scala sources to your Scala build.

gins>
<plugin>
    <groupId>at.makubi.maven.plugin</groupId>
    <artifactId>avrohugger-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate-scala-sources</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>add-generated-sources</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sourceDir>${project.build.directory}/generated-sources/avro</sourceDir>
            </configuration>
        </execution>
        <execution>
            <goals>
                <goal>compile</goal>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
    ...
</plugin>
ugins>
Override variables

You can override the following variables in the plugin configuration:

sourceDirectory outputDirectory recursive limitedNumberOfFieldsInCaseClasses sourceGenerationFormat namespaceMapping Example

To override the sourceDirectory and outputDirectory, use

gins>
<plugin>
    <groupId>at.makubi.maven.plugin</groupId>
    <artifactId>avrohugger-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate-scala-sources</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <sourceDirectory>src/main/resources/avro</sourceDirectory>
        <outputDirectory>target/generated-sources</outputDirectory>
    </configuration>
</plugin>
ugins>

To override the sourceDirectory, outputDirectory, recurse over sourceDirectory, and restrict generated class fields to be compatible with Scala 2.10 use

gins>
<plugin>
    <groupId>at.makubi.maven.plugin</groupId>
    <artifactId>avrohugger-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate-scala-sources</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <sourceDirectory>src/main/resources/avro</sourceDirectory>
        <outputDirectory>target/generated-sources</outputDirectory>
        <recursive>true</recursive>
        <limitedNumberOfFieldsInCaseClasses>true</limitedNumberOfFieldsInCaseClasses>>
    </configuration>
</plugin>
ugins>

To override the namespaceMapping of Avro protocols under the com.example.packagename namespace to com.example.packagenamechanged

gins>
<plugin>
    <groupId>at.makubi.maven.plugin</groupId>
    <artifactId>avrohugger-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate-scala-sources</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <namespaceMapping>
            <mapping>
                <from>com.example.packagename</from>
                <to>com.example.packagenamechanged</to>
            </mapping>
        </namespaceMapping>
    </configuration>
</plugin>
ugins>
Dependencies

This plugin heavily relies on Avrohugger to generate Scala code.

Contributors
License

The Avrohugger Maven Plugin is released under version 2.0 of the Apache License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.