Compiling Annotation Handler in IntelliJ IDEA

I am using the latest version of IntelliJ IDEA (13.1.4), and I am developing my own annotation.

I currently have two modules in my project

  • MyOwnCustomAnnotationProcessor (here I have the actual processor)
  • MyOwnCustomAnnotationProcessorTest (I basically have a couple of classes annotated to see if this all generates)

I worked in Eclipse, but I'm trying to switch from IntelliJ because I cannot stand Eclipse. I managed to do this in Eclipse by creating an Ant construct that creates the .jar file of the main project, and the Test classes will use this .jar.

But I can not get it to work on IntelliJ.

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

Annotation processor screen

I also tried changing the Processor Path to the output folder (where there are n META-INF classes), but no luck. The generated folder is created by the IDE, but does not find any processors.

How can you continue here?

+6
source share
1 answer

In the end, I found how to do this if someone is interested:

  • In the Project Structure menu, add artifact to the main project (annotation processor project). This artifact exports a .jar file with an annotation processor. Be sure to enable Build on Make , so a new .jar will be generated every time you request a Rebuild Project
  • In Settings - > Compiler -> Annotation Processor Turn on annotation processing, check the Processor Path and place the path to the exported .jar file. Do not forget to put the processor.

and everything should be. Now every time a rebuilt project is clicked, a new bank is created and a second project will be generated with this new bank.

+14
source

Source: https://habr.com/ru/post/974353/


All Articles