You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Russell Gold <ru...@oracle.com> on 2012/04/03 17:17:05 UTC

Annotation processing?

Does anybody have a working example of custom annotation processing in Maven that they could share? I'm finding the documentation on this to be frustratingly sparse. I can find a page claiming to describe a plugin for annotation processing, but it doesn't actually give examples of what it's supposed to do or how to use it.

Also, how do you search the mailing list archives? I had expected that to be a FAQ, but there doesn't appear to be a FAQ for this list.

Thanks in advance,
Russ
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Annotation processing?

Posted by Wayne Fay <wa...@gmail.com>.
> Mostly, I'm trying to figure out why my implementation - which conforms to
> the documentation I'd found - does not appear to be detected by the compiler.
> I get that I'm doing something wrong; I just don't know what.  I'll examine the
> code Curtis pointed out and see if it gives me clues.

The first step is always to make it work with plain jane javac
first... Then you should have no trouble making it work with Maven
since the compiler plugin just basically reaches out to your JDK to
perform the annotation and compilation steps. You simply need to
configure the plugin properly once you know (for sure!) it works with
javac.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Annotation processing?

Posted by Russell Gold <ru...@oracle.com>.
Mostly, I'm trying to figure out why my implementation - which conforms to the documentation I'd found - does not appear to be detected by the compiler. I get that I'm doing something wrong; I just don't know what.  I'll examine the code Curtis pointed out and see if it gives me clues.

On Apr 3, 2012, at 12:01 PM, Wayne Fay wrote:

>> Does anybody have a working example of custom annotation processing
>> in Maven that they could share? I'm finding the documentation on this to
> 
> I will assume that Curtis' reply was sufficient information. If not,
> please provide more specific information about what you are looking
> for.
> 
>> Also, how do you search the mailing list archives? I had expected
>> that to be a FAQ, but there doesn't appear to be a FAQ for this list.
> 
> Nabble.com provides a search interface for the mailing list:
> http://maven.40175.n5.nabble.com/
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Annotation processing?

Posted by Wayne Fay <wa...@gmail.com>.
> Does anybody have a working example of custom annotation processing
> in Maven that they could share? I'm finding the documentation on this to

I will assume that Curtis' reply was sufficient information. If not,
please provide more specific information about what you are looking
for.

> Also, how do you search the mailing list archives? I had expected
> that to be a FAQ, but there doesn't appear to be a FAQ for this list.

Nabble.com provides a search interface for the mailing list:
http://maven.40175.n5.nabble.com/

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Annotation processing?

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi Russ,


Does anybody have a working example of custom annotation processing in
> Maven that they could share? I'm finding the documentation on this to be
> frustratingly sparse. I can find a page claiming to describe a plugin for
> annotation processing, but it doesn't actually give examples of what it's
> supposed to do or how to use it.
>

I agree that documentation on custom annotation processing is hard to find.

My team uses a library called SezPoz (http://sezpoz.java.net/) which
provides a custom annotation processor, which operates at compile time
using Java6's Pluggable Annotation Processing API.

Since command-line Maven uses the installed system Java, which will usually
be either Oracle's Javac or the OpenJDK one, such custom annotation
processors will function as long as you are running at least Java6. (With
Java5 it is also possible, but you have to jump through some extra hoops.)

So for my team, our SezPoz-related annotations "just work" with no
additional configuration within Maven whatsoever.

If you need to write your own custom annotation processor, you could study
the SezPoz source code for a working example.

For further reading, you can check the Javadocs:

http://docs.oracle.com/javase/6/docs/api/javax/annotation/processing/Processor.html

If you meant some sort of Maven-specific custom annotation processing, then
I don't know of such a feature. But as I said, Maven (via Javac) should
invoke your annotation processors out of the box.

HTH,
Curtis

P.S. Beware of Eclipse: it does not run compile-time annotation processors
automatically, but must be specifically configured to do so:

http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_apt_getting_started.htm
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=280542

For our projects with SezPoz, we commit two key files to the VCS to force
Eclipse to behave properly immediately (rather than needing to dig around
in the Eclipse project settings UI):
    https://github.com/imagej/imagej/blob/master/core/core/.factorypath

https://github.com/imagej/imagej/blob/master/core/core/.settings/org.eclipse.jdt.apt.core.prefs


On Tue, Apr 3, 2012 at 10:17 AM, Russell Gold <ru...@oracle.com>wrote:

> Does anybody have a working example of custom annotation processing in
> Maven that they could share? I'm finding the documentation on this to be
> frustratingly sparse. I can find a page claiming to describe a plugin for
> annotation processing, but it doesn't actually give examples of what it's
> supposed to do or how to use it.
>
> Also, how do you search the mailing list archives? I had expected that to
> be a FAQ, but there doesn't appear to be a FAQ for this list.
>
> Thanks in advance,
> Russ
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>