Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Annotation Processor not run
Annotation Processor not run [message #249916] Sat, 01 December 2007 22:01 Go to next message
Eclipse UserFriend
Hi,

I'm trying to get my annotation processor running in eclipse 3.3.0

At the moment, my processor is extremely simple, essentially the same as
the sample one in
http://java.sun.com/j2se/1.5.0/docs/guide/apt/GettingStarted .html.

I compile the processor and jar it. However, I cannot make it run by the
Eclipse itself after I follow everything in
http://www.eclipse.org/jdt/apt/introToAPT.html. There is no error reported
in the Problem view or the .log file.

I can make it run using ant build from within my Eclipse project. The JAR
has appropriate META-INF file as requested and Ant apt picks up without
any trouble.

Please help!

Thanks
Re: Annotation Processor not run [message #249920 is a reply to message #249916] Sat, 01 December 2007 22:09 Go to previous messageGo to next message
Eclipse UserFriend
hackingbear wrote:
> I compile the processor and jar it. However, I cannot make it run by the
> Eclipse itself after I follow everything in
> http://www.eclipse.org/jdt/apt/introToAPT.html. There is no error reported
> in the Problem view or the .log file.

> I can make it run using ant build from within my Eclipse project. The JAR
> has appropriate META-INF file as requested and Ant apt picks up without
> any trouble.

BTW Eclipse recognizes the processor factory in the project's Factory
Paths | Advanced Options dialog, but does run it.
Annotation Processor not run automatically [message #249946 is a reply to message #249920] Sun, 02 December 2007 13:48 Go to previous messageGo to next message
Eclipse UserFriend
OK, I nail down the problem further:

I have two projects running the APT.

Proj1 is plug-in project. For this one, the APT run is triggered only if I
manually change the project's Annotation Processing settings (like disable
and then enable) which would bring up the confirmation dialog to run build
the project. APT is not run if I just clean the project. Or invoke "Build
Project"

Proj2 is a regular project. This one would run APT when clean the project.

My annotation processor is srt to run in batch mode.

Now there is another problem common to both of the above:

After I got the project run the APT laboriously and produce a .properties
files in the .apt_generated folder, the resulting file is not copied to
the output folder and so not visible at run-time.

Any clue to these problems?

Thanks
Re: Annotation Processor not run automatically [message #249962 is a reply to message #249946] Mon, 03 December 2007 14:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"hackingbear" <cutebear103@hotmail.com> wrote in message
news:a633bec87e8f1f56378a1516fa9d4aac$1@www.eclipse.org...
> My annotation processor is srt to run in batch mode.

Correct, if your processor is set to run in batch mode, then it will only be
called when you do a full build. Batch mode is unpleasant. It's really
only there to deal with a few pre-existing processors that did things like
keeping pass counters in static variables: in batch mode we throw out the
whole classloader on every build, so that statics get re-initialized. It
also helps address the problem of processors that assume they will be able
to process every source file on every build, which again is not a valid
assumption in an IDE because of incremental builds.

Why do you have your processor set that way? Is it because you're trying to
create a composite file, that is, a single file that contains information
gathered from all your source files? You might, in that case, have better
luck writing a processor based on the Java 6 annotation processing API
(javax.annotation.processing). Or you might want some sort of two-stage
design, where your processor creates intermediate files that are then glued
together into a single composite file by a separate Builder. With the Java
5 API it is practically impossible to get composite files to work right in
an IDE. With Java 6 it is still really hard, but at least it's possible.
Sun doesn't seem to have given much consideration to incremental compilation
in their API design.


> After I got the project run the APT laboriously and produce a .properties
> files in the .apt_generated folder, the resulting file is not copied to
> the output folder and so not visible at run-time.

I'm not sure why that would be. You can try playing with that one by
manually creating files in the .apt_generated folder and seeing if they get
copied. Check filters, exclusions, details of the build.properties file?


-Walter Harley
JDT APT team
Re: Annotation Processor not run automatically [message #250071 is a reply to message #249962] Thu, 06 December 2007 17:50 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the reply. I will check the resource not copied problem.

I have a Java 1.5 APT so will update to the Java SE 6 one.
Re: Annotation Processor not run automatically [message #250110 is a reply to message #249962] Sun, 09 December 2007 19:02 Go to previous message
Eclipse UserFriend
Walter Harley wrote:
>> After I got the project run the APT laboriously and produce a .properties
>> files in the .apt_generated folder, the resulting file is not copied to
>> the output folder and so not visible at run-time.

> I'm not sure why that would be. You can try playing with that one by
> manually creating files in the .apt_generated folder and seeing if they get
> copied. Check filters, exclusions, details of the build.properties file?

I carefully test this. First turn off my ant builder which copy over the
file to bin/. If I "new" a file under .apt_generated/, the file is copied
over. but if I delete the APT generated files, do either a clean under
auto-build or a manual build, the generated files do not get copied over
to bin/. I try to create my own generated/ folder and switch APT to use
that, but still does not work.

is this a bug?
Previous Topic:ResourceChangeListener problems
Next Topic:Listening to which refactorings are available
Goto Forum:
  


Current Time: Wed May 07 16:58:57 EDT 2025

Powered by FUDForum. Page generated in 0.07328 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top