Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annotation Processor compilation in IntelliJ IDEA

I'm using the latest version of IntelliJ IDEA (13.1.4) and I'm developing my own custom annotation.

I currently have two modules on my project

  • MyOwnCustomAnnotationProcessor (here I have the actual processor)
  • MyOwnCustomAnnotationProcessorTest (this I basically have a couple classes annotated to see if it's all generating fine)

I was working in Eclipse but I'm trying to migrate ot IntelliJ because I can't stand Eclipse. I managed to make it kinda-of work in Eclipse by having an Ant build generating the .jar file of the main project and the Test classes would use this .jar.

But I can't make it work on IntelliJ.

In Settings -> Compiler -> Annotation Processor I have a new profile, the test project is inside this profile, the profile is like:

Annotation processor screen

I've also tried changing the Processor Path to the output folder (where there're classes n META-INF) but no luck. The generated folder is being created by the IDE, but it's not finding any processors.

Any tip on how to proceed here?

like image 240
Budius Avatar asked Aug 26 '14 09:08

Budius


1 Answers

I ended up finding how to do it, if anyone is interested:

  • In Project Structure menu add an artifact to the main project (the annotation processor project). This artifact exports a .jar file with the annotation processor. Make sure to enable Build on Make, that way a new .jar will be generated every time you ask to Rebuild Project
  • In Settings - > Compiler -> Annotation Processor Enable annotation processing, check Processor Path and put the path of the exported .jar file. Make sure to put the processor.

and that should be all. Now everytime rebuilt project is clicked a new jar is generated and the second project will be re-generated with that new jar.

like image 65
Budius Avatar answered Oct 14 '22 14:10

Budius