Using Annotation Processors

I'm having trouble with the Annotation Processor support.  I am trying to use a combination of existing some existing processors from the gwtp library (@GenEvent), as well as some custom processors I have written myself.  I have confirmed that the processors work in isolation, generating the expected code.  My problem is that I'm having difficulting figuring out how to get this integrated into my project build.

Here's what I'd like to happen:

* pick up processors from the classpath, including my dependent modules
* if the java code in my module using the annotations changes, regenerate the generated files
* Generate files before trying to compile anything else in the module since there is no point in trying to build other classes until the generated sources are up to date
* If I make a change in my custom annotation processor, regenerate all related files

What I'm actually seeing is that the annotation processing seems to happen intermittently.  Sometimes it happens when I compile the module, sometimes it doesn't.  I haven't been able to figure out what triggers the different behaviors.

Originally I had my custom processors in the same module as the code being processed, but that seemed to confuse the issue, so I moved them into a prerequisite module.  I have added the generated source directory as a content root in my module.  As far as the annotation processing settings go, I have enabled the feature and specified that it should pick up processors from the classpath.  This seems to generally work for the processors coming from the external .jar, but it doesn't pick up my custom processors.

I've been able to get this working from a stand alone external ant fle by using a separate generate sources target that builds the processors then generates sources.  I can run this target before my main compile to ensure everything is up to date.  I just haven't been able to figure out how to get this all working from inside IntelliJ.

Has anyone else gotten custom processors that generate sources working?

Please sign in to leave a comment.