avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tl ...@rat.io>
Subject Re: Autogenerating Java classes from IDL
Date Mon, 01 Feb 2016 14:03:18 GMT

> On 31.01.2016, at 01:13, Evan McClain <aeroevan@gmail.com> wrote:
> I have used IDLs with the avro-maven-plugin and that worked for me.
> Evan

Maven is black art for me but your answer encouraged me to stare at the command line output
of avro-tools again (since I considered it improbable that the maven-plugin can invoke things
that the CLI can't). "idl2schemata" does indeed provide a good part of what I want in that
it omits the protocol declarations and only transforms the schema parts.

I guess that Maven would allow me to set up a process where Java classes would be generated
from the JSON schemata that idl2schemata extracts from the IDL protocol definition but I’m
having trouble figuring out how to configure the POM. 

Just to prove that I’m not totally useless I googled me the following snippet that should
generate classes from a schema.


I reckon that a similar instruction, preceding this one, could initiate the conversion from
an IDl to a schema (like the CLI tool does with "idl2schema"). What should the relevant snippet
look like?



> On Sat, Jan 30, 2016, 8:52 AM tl <tl@rat.io> wrote:
> Hi,
> I started working with Avro only recently so maybe I missed something but it seems to
me that schemas can be defined in JSON as well as in IDL but only from JSON schemas can builder
classes be autogenerated. This is a pity since IDLs are much easier to write and read than
the JSON representation.
> I wrote a few IDL schemas, converted them to avpr and tweaked those avpr files to become
valid avsc schema files from which I autogenerated the classes. This is a rather convoluted
process. I wouldn’t mind so much if I wouldn’t know that I or somebody else will have
to update the schemas and classes from time to time. This doesn’t look like a robust workflow.
> Deleting the IDLs and avpr files and doing updates only in the avsc schemas reduces the
workflow to 2 steps but I loose the nice properties of IDLs [0].
> Using only generic mapping would reduce the workflow by one step too but I’d loose
static type checking.
> I’d love to be able to autogenerate the Java classes from the IDLs directly. Is there
a way?
> Regards,
> Thomas
> [0] Regarding IDLs it would be cool if I could forward reference objects in the schema
or even write nested schemas but that’s a relatively minor gripe.

View raw message