|
|
-
Configuring avro-maven-plugin to generate java classes with non-default field properties
Pankaj Shroff 2013-03-14, 06:53
Hi
In the OpenRTB reference implementation, I use the avro-maven-plugin exclusively to generate java classes from .avpr protocol definition files. Since release 1.6.1 of Avro (I believe), the avro SpecificCompiler defaults to marking the fields of generated classes to be PUBLIC_DEPRECATED (@Deprecated directive and public scope) by default. Reading the archives and the patch that changed this behavior since 1.5.x, I know that one can use SpecificCompiler in java code and call setFieldProperties to change the default behavior. But is there also any way to change this using the apache-maven-plugin ?
I was hoping for examples of pom.xml that show how to add <configuration> parameters to the avro-maven-plugin so that generated java sources have field properties PUBLIC or PRIVATE and not PUBLIC_DEPRECATED (default).
Thanks in advance.
-- Pankaj Shroff [EMAIL PROTECTED]
-
Re: Configuring avro-maven-plugin to generate java classes with non-default field properties
Doug Cutting 2013-03-14, 22:11
The fieldVisibility tag can be added to the avro-maven-plugin configuration in your pom.xml.
For example:
<configuration> ... <fieldVisibility>private</fieldVisibility> ... </configuration>
Accepted values are "public", "private" and "public_deprecated" (the default).
Doug
On Wed, Mar 13, 2013 at 11:53 PM, Pankaj Shroff <[EMAIL PROTECTED]> wrote: > Hi > > In the OpenRTB reference implementation, I use the avro-maven-plugin > exclusively to generate java classes from .avpr protocol definition files. > Since release 1.6.1 of Avro (I believe), the avro SpecificCompiler defaults > to marking the fields of generated classes to be PUBLIC_DEPRECATED > (@Deprecated directive and public scope) by default. Reading the archives > and the patch that changed this behavior since 1.5.x, I know that one can > use SpecificCompiler in java code and call setFieldProperties to change the > default behavior. But is there also any way to change this using the > apache-maven-plugin ? > > I was hoping for examples of pom.xml that show how to add <configuration> > parameters to the avro-maven-plugin so that generated java sources have > field properties PUBLIC or PRIVATE and not PUBLIC_DEPRECATED (default). > > Thanks in advance. > > -- > Pankaj Shroff > [EMAIL PROTECTED]
-
Re: Configuring avro-maven-plugin to generate java classes with non-default field properties
Pankaj Shroff 2013-03-15, 09:06
thanks doug!
On Thu, Mar 14, 2013 at 6:11 PM, Doug Cutting <[EMAIL PROTECTED]> wrote:
> The fieldVisibility tag can be added to the avro-maven-plugin > configuration in your pom.xml. > > For example: > > <configuration> > ... > <fieldVisibility>private</fieldVisibility> > ... > </configuration> > > Accepted values are "public", "private" and "public_deprecated" (the > default). > > Doug > > On Wed, Mar 13, 2013 at 11:53 PM, Pankaj Shroff <[EMAIL PROTECTED]> wrote: > > Hi > > > > In the OpenRTB reference implementation, I use the avro-maven-plugin > > exclusively to generate java classes from .avpr protocol definition > files. > > Since release 1.6.1 of Avro (I believe), the avro SpecificCompiler > defaults > > to marking the fields of generated classes to be PUBLIC_DEPRECATED > > (@Deprecated directive and public scope) by default. Reading the archives > > and the patch that changed this behavior since 1.5.x, I know that one can > > use SpecificCompiler in java code and call setFieldProperties to change > the > > default behavior. But is there also any way to change this using the > > apache-maven-plugin ? > > > > I was hoping for examples of pom.xml that show how to add <configuration> > > parameters to the avro-maven-plugin so that generated java sources have > > field properties PUBLIC or PRIVATE and not PUBLIC_DEPRECATED (default). > > > > Thanks in advance. > > > > -- > > Pankaj Shroff > > [EMAIL PROTECTED] >
-- Pankaj Shroff [EMAIL PROTECTED]
-
Re: Configuring avro-maven-plugin to generate java classes with non-default field properties
Pankaj Shroff 2013-03-15, 16:19
Interesting observation, could be of value to someone: when I tried what Doug suggested - at first a mvn clean install did not pick up the change in the avro-maven-plugin configuration (or so it seemed). Because the generated java files were still showing @deprecated directives. I had to manually delete the *.java files and run mvn clean install again to regenerate the java sources. This worked.
Sounds like something wrong in my maven setup, in my project pom.xml or in the avro-maven-plugin behavior when the build target is "clean" (i.e. rebuild all).
Pankaj
On Fri, Mar 15, 2013 at 5:06 AM, Pankaj Shroff <[EMAIL PROTECTED]> wrote:
> thanks doug! > > > > On Thu, Mar 14, 2013 at 6:11 PM, Doug Cutting <[EMAIL PROTECTED]> wrote: > >> The fieldVisibility tag can be added to the avro-maven-plugin >> configuration in your pom.xml. >> >> For example: >> >> <configuration> >> ... >> <fieldVisibility>private</fieldVisibility> >> ... >> </configuration> >> >> Accepted values are "public", "private" and "public_deprecated" (the >> default). >> >> Doug >> >> On Wed, Mar 13, 2013 at 11:53 PM, Pankaj Shroff <[EMAIL PROTECTED]> >> wrote: >> > Hi >> > >> > In the OpenRTB reference implementation, I use the avro-maven-plugin >> > exclusively to generate java classes from .avpr protocol definition >> files. >> > Since release 1.6.1 of Avro (I believe), the avro SpecificCompiler >> defaults >> > to marking the fields of generated classes to be PUBLIC_DEPRECATED >> > (@Deprecated directive and public scope) by default. Reading the >> archives >> > and the patch that changed this behavior since 1.5.x, I know that one >> can >> > use SpecificCompiler in java code and call setFieldProperties to change >> the >> > default behavior. But is there also any way to change this using the >> > apache-maven-plugin ? >> > >> > I was hoping for examples of pom.xml that show how to add >> <configuration> >> > parameters to the avro-maven-plugin so that generated java sources have >> > field properties PUBLIC or PRIVATE and not PUBLIC_DEPRECATED (default). >> > >> > Thanks in advance. >> > >> > -- >> > Pankaj Shroff >> > [EMAIL PROTECTED] >> > > > > -- > Pankaj Shroff > [EMAIL PROTECTED] >
-- Pankaj Shroff [EMAIL PROTECTED]
|
|