Compilation error for annotations in Java 1.8 and IntelliJ IDEA 14

naXa picture naXa · Oct 8, 2015 · Viewed 10.2k times · Source

I was playing with Java annotation processing. Application build fails in IntelliJ IDEA, while a maven build ends successfully. I am sure that provider class exists, yet I get the following error:

java: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider <my class> not found.

I suppose that's because of a module X, that should be compiled with -proc:none argument. But I need annotation processing to be enabled for the rest of application. How to configure IntelliJ IDEA build proccess to skip a specific module during annotation proccessing?

Answer

naXa picture naXa · Oct 8, 2015

You need to configure a separate annotation profile for your module.

  1. Create an annotation profile
    1. In the Annotation Processors page, click add.
    2. In the 'Create new profile' dialog box, specify the profile name.
  2. Associate a module with an annotation profile
    1. Select your module in the list of modules under a default profile. (By default, all the modules of a project are associated with the default profile.)
    2. Click Move to, or press F6.
    3. From the drop-down list, select the target profile to move the selected module to. Annotation profile - move
  3. Configure annotation processing for a profile
    1. Enable annotation processing for the default profile.
    2. Disable annotation processing for the profile, you've just created.

This answer is based on an article from IntelliJ IDEA Help.