10

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?

Budius
  • 39,391
  • 16
  • 102
  • 144

1 Answers1

19

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.

Dziugas
  • 1,500
  • 1
  • 12
  • 28
Budius
  • 39,391
  • 16
  • 102
  • 144
  • Did you by some chance find out how to debug an annotation processor in Intellij. I've set up remote debug configuration, and added compiler option -J-agentlib:jdwp=dt_transport=socket,server=y,suspend=y,address=5005 , selected javac, but the compiler just wont suspend. Ive tested other compiler options and they are passed, also invalid options, and they do cause error. This exact scheme works in NetBeans for example. – irpbc Apr 29 '15 at 13:36
  • @iRasic sorry, no. I was just doing some investigation and playing back on those time, but never digged deeper on it. – Budius Apr 29 '15 at 13:53
  • 2
    THANK YOU VERY MUCH. You solved me a big issue. I wish I could invite you to coffee. Around London? – Mohamed Taher Alrefaie Jun 27 '15 at 13:40