You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Deepak Nettem <de...@gmail.com> on 2012/03/30 15:32:10 UTC
Code Generation from avsc files
Hi,
I have a .avsc schema file in my maven project, and I am able to use it to
write simple avro apps. However, I am not able to generate source code
(classes) from the avro schema file to be able to use them in Avro
MapReduce code.
My pom.xml plugins section looks like this:
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.avrotest.App</mainClass>
</manifest>
</archive>
<manifestEntries>
<Class-Path>../target/classes</Class-Path>
</manifestEntries>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.6.1</version>
</plugin>
</plugins>
I package my jar by running
mvn compile
mvn assembly:single
Best,
Deepak
Re: Code Generation from avsc files
Posted by Deepak Nettem <de...@gmail.com>.
Thanks! That worked!
On Fri, Mar 30, 2012 at 9:57 AM, Jeremy Lewi <je...@lewi.us> wrote:
> I think your plugin configuration might be missing some lines.
>
> Here's what mine looks like:
> <plugin>
> <groupId>org.apache.avro</groupId>
> <artifactId>avro-maven-plugin</artifactId>
> <version>${avro-version}</version>
> <executions>
> <execution>
> <id>schemas</id>
> <phase>generate-sources</phase>
> <goals>
> <goal>protocol</goal>
> </goals>
> <configuration>
> <includes>
> <include>*.avpr</include>
> </includes>
>
> <sourceDirectory>${project.basedir}/share/schemas/contrail/</sourceDirectory>
>
> <outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
> </configuration>
> </execution>
> </executions>
> </plugin>
>
> I don't know if the compiler works with avsc files but assuming it does,
> you'll probably need to either change or add an appropriate include:
> e.g
> <include> *.avsc</include>
> You'll also want to change the sourcedirectory to the directory where your
> schema files are located.
>
> J
>
> On Fri, Mar 30, 2012 at 6:32 AM, Deepak Nettem <de...@gmail.com>wrote:
>
>> Hi,
>>
>> I have a .avsc schema file in my maven project, and I am able to use it
>> to write simple avro apps. However, I am not able to generate source code
>> (classes) from the avro schema file to be able to use them in Avro
>> MapReduce code.
>>
>> My pom.xml plugins section looks like this:
>>
>> <plugins>
>> <plugin>
>> <artifactId>maven-assembly-plugin</artifactId>
>> <configuration>
>> <archive>
>> <manifest>
>> <mainClass>org.avrotest.App</mainClass>
>> </manifest>
>> </archive>
>> <manifestEntries>
>> <Class-Path>../target/classes</Class-Path>
>> </manifestEntries>
>> <descriptorRefs>
>> <descriptorRef>jar-with-dependencies</descriptorRef>
>> </descriptorRefs>
>> </configuration>
>> </plugin>
>>
>> <plugin>
>> <groupId>org.apache.avro</groupId>
>> <artifactId>avro-maven-plugin</artifactId>
>> <version>1.6.1</version>
>> </plugin>
>> </plugins>
>>
>> I package my jar by running
>>
>> mvn compile
>> mvn assembly:single
>>
>> Best,
>> Deepak
>>
>
>
Re: Code Generation from avsc files
Posted by Jeremy Lewi <je...@lewi.us>.
I think your plugin configuration might be missing some lines.
Here's what mine looks like:
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro-version}</version>
<executions>
<execution>
<id>schemas</id>
<phase>generate-sources</phase>
<goals>
<goal>protocol</goal>
</goals>
<configuration>
<includes>
<include>*.avpr</include>
</includes>
<sourceDirectory>${project.basedir}/share/schemas/contrail/</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
I don't know if the compiler works with avsc files but assuming it does,
you'll probably need to either change or add an appropriate include:
e.g
<include> *.avsc</include>
You'll also want to change the sourcedirectory to the directory where your
schema files are located.
J
On Fri, Mar 30, 2012 at 6:32 AM, Deepak Nettem <de...@gmail.com>wrote:
> Hi,
>
> I have a .avsc schema file in my maven project, and I am able to use it to
> write simple avro apps. However, I am not able to generate source code
> (classes) from the avro schema file to be able to use them in Avro
> MapReduce code.
>
> My pom.xml plugins section looks like this:
>
> <plugins>
> <plugin>
> <artifactId>maven-assembly-plugin</artifactId>
> <configuration>
> <archive>
> <manifest>
> <mainClass>org.avrotest.App</mainClass>
> </manifest>
> </archive>
> <manifestEntries>
> <Class-Path>../target/classes</Class-Path>
> </manifestEntries>
> <descriptorRefs>
> <descriptorRef>jar-with-dependencies</descriptorRef>
> </descriptorRefs>
> </configuration>
> </plugin>
>
> <plugin>
> <groupId>org.apache.avro</groupId>
> <artifactId>avro-maven-plugin</artifactId>
> <version>1.6.1</version>
> </plugin>
> </plugins>
>
> I package my jar by running
>
> mvn compile
> mvn assembly:single
>
> Best,
> Deepak
>