| Annotation Processing Without A Plugin [message #495476] |
Wed, 04 November 2009 20:49  |
Phil Troy Messages: 4 Registered: July 2009 |
Junior Member |
|
|
Hi!
I am trying to move a netbeans project into eclipse. The project was originally in eclipse but I needed access to an annotation processing capability (that could be run from within the ide). I and another individual have built a few annotations and an annotation processor. I have looked at earlier postings in this forum about annotation processing but they seem to be for earlier versions of the annotation processing capability (I am using java se 6), or require a plug-in (which I am trying to avoid). I had already debugged the annotation processor under netbeans, though I have since added some logging code.
I have created a project for that annotation processor. For the project that uses the annotation processor, I have specified in file project properties (inside eclipse):
- enable project specific settings
- compiler compliance level 1.6
- use default compliance settings
- enable annotation processing
- disabled processing in editor (I read somewhere that it doesn't work for Java 6)
- specified the generated source directory to be src/com/troyware/constants
- specified the factory path of the jar to be TROYWAREAnnotationProcessors/TROYWAREAnnotationProcessors.ja r
- maximum number of problems per compilation unit to 500
I am attaching the annotation processor folders en mass
TROYWAREAnnotationProcessors.zip
Besides all of that:
- my workspace is D:/TroywareEclipseJavaProjectsWorkspace
- My source code (several projects including the annotation processor) is in E:/TROYWAREEclipseJavaProjects; the bin folder and classpath .project files are there also inside each project
My questions are:
- How do I show more than 100 errors (so I can see if there are errors caused by the annotation processor - but I am pretty sure there are not)
- How do I get this to work without using plug-ins
I would really appreciate some help. This can be another eclipse success story; or I could be forced to go back to netbeans (which is buggy and whose editor makes it very hard for me to work the way I would like to work).
Thanks . . .
Phil
P.S. Effective 20091030, I have modified my annotation processor, and made sure that it works from the command line via javac. Thus I can work in Eclipse but still have to go outside of Eclipse as the annotation processor still does not work in Eclipse. I am wondering whether the manifest in the jar file (which didn't have much in it) was correct and if not exactly what it should contain.
P.P.S. I would like to try to develop plug ins for eclipse (for other reasons) and would really appreciate a step by step example - the ones I've found to date tend to gloss over steps that may be obvious to some people but not to me.
|
|
|
|
|
| Re: Annotation Processing Without A Plugin [message #495513 is a reply to message #495476 ] |
Thu, 05 November 2009 02:52  |
Walter Harley Messages: 571 Registered: July 2009 |
Senior Member |
|
|
Phil Troy wrote:
> Hi!
> I am trying to move a netbeans project into eclipse. The project was
> originally in eclipse but I needed access to an annotation processing
> capability (that could be run from within the ide). I and another
> individual have built a few annotations and an annotation processor. I
> have looked at earlier postings in this forum about annotation
> processing but they seem to be for earlier versions of the annotation
> processing capability (I am using java se 6), or require a plug-in
> (which I am trying to avoid). I had already debugged the annotation
> processor under netbeans, though I have since added some logging code.
> I have created a project for that annotation processor. For the project
> that uses the annotation processor, I have specified in file project
> properties (inside eclipse): - enable project specific settings -
> compiler compliance level 1.6 - use default compliance settings - enable
> annotation processing - disabled processing in editor (I read somewhere
> that it doesn't work for Java 6) - specified the generated source
> directory to be src/com/troyware/constants - specified the factory path
> of the jar to be
> TROYWAREAnnotationProcessors/TROYWAREAnnotationProcessors.ja r - maximum
> number of problems per compilation unit to 500
> I am attaching the annotation processor folders en mass
> TROYWAREAnnotationProcessors.zip
Attachments don't seem to work on this newsgroup. Do feel free to file a bug;
worst case, we'll look at it and figure out what you're doing wrong.
The most common mistake in creating a processor jar is to omit, or incorrectly
format, the META-INF/services entry. Your jar needs to include a folder named
META-INF/services (that is, a subfolder of META-INF, where your MANIFEST.MF
typically lives); and that folder needs to contain a text file named
javax.annotation.processing.Processor, that is, the name of the interface you're
implementing. The text file should then contain one line for each processor
class, containing the fully qualified classname of the processor.
But if you've got it working with javac, then it seems likely you've already
done that step. In that case I'll need to take a look at your processor to
figure out what's not happening - easiest if you attach it to a bug report.
FWIW, the best available tutorials for writing annotation processors for Eclipse
are those linked from the JDT-APT web page, at http://www.eclipse.org/jdt/apt .
But you're right that they're rather out of date, and mostly aimed at Java 5
processors (though I believe there is a zipped-up sample Java 6 processor
included, IIRC).
> My questions are: - How do I show more than 100 errors
I think you'll need to edit the Preferences for the problems view pane, to see
more than the default 100. Drop down the down-arrow at top right of the pane to
get the view menu; one of the options should be Preferences.
(so I can see if
> there are errors caused by the annotation processor - but I am pretty
> sure there are not) - How do I get this to work without using plug-ins
> I would really appreciate some help.
It's actually not hard to have a processor be *both* a plugin and a jar, that
is, usable from javac but also easier to deploy in Eclipse. The 2007 EclipseCon
tutorial has some detail on this, and the sample code in there is structured
that way. I've gotten in the habit of doing that routinely for all the
processors I write; it just makes development easier. But it's not necessary;
you can also do either-or.
|
|
|