Disabling of annotation processing is lost on maven reimport

Answered

In our project we disable annotation processing (settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors) for the profile "Maven default annotation processors profile".

But every time a Maven reimport ist executed (e.g. editing a pom.xml file) the setting is reverted and the annotation processing ist enabled again.

We also tried to move the modules into another Annotation Processor profile but the setting is still reverted.

How can i stop IntelliJ from resetting this?

4
17 comments

Try disabling it for the default project. File | Other Settings | Default Settings.

0

Thanks for the quick answer.

I already tried this as well (sorry, forgot to mention it in my first post) - but the default setting for Annotation Processors of the default project is already disabled (and remains disabled when the other settings gets automatically enabled again).

0

Done - thanks for the reference to the issue...

1

Great. What version will include this change (feature) ?

0

The fix version is undefined at the moment.

0

Is there any update on this? It is still happening for me. When I add a custom annotation profile and move the module to it... after the maven reimport the module gets reset back to the default profile.

0

Hello,

I asked developers to share plans for the issue on YouTrack.

0

Same issue here at Intellij IDEA 2018.2 Build #IC-182.3684.101 ON July 24, 2018

0

Similar issue here (IntelliJ IDEA 2018.2.7 Build #IC-182.5107.41):

We have the annotation processing enabled and "Obtain processors from project classpath" checked.

Every time Maven re-imports IntelliJ automatically switches to "Processor path:" instead and fills the field with a huge list of .jars from my local maven repository (everything from JodaTime to whatnot). At some point that list must be faulty, because the project does not build anymore afterwards.

This is the list IntelliJ finds:

C:\Users\tobias.weber\.m2\repository\org\mapstruct\mapstruct-processor\1.3.0.Final\mapstruct-processor-1.3.0.Final.jar;
C:\Users\tobias.weber\.m2\repository\com\jolira\hickory\1.0.0\hickory-1.0.0.jar;
C:\Users\tobias.weber\.m2\repository\org\mapstruct\mapstruct\1.3.0.Final\mapstruct-1.3.0.Final.jar;
C:\Users\tobias.weber\.m2\repository\junit\junit\4.12\junit-4.12.jar;
C:\Users\tobias.weber\.m2\repository\org\assertj\assertj-core\3.11.1\assertj-core-3.11.1.jar;
C:\Users\tobias.weber\.m2\repository\com\google\guava\guava\19.0\guava-19.0.jar;
C:\Users\tobias.weber\.m2\repository\com\puppycrawl\tools\checkstyle\8.14\checkstyle-8.14.jar;
C:\Users\tobias.weber\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;
C:\Users\tobias.weber\.m2\repository\org\codehaus\plexus\plexus-container-default\1.6\plexus-container-default-1.6.jar;
C:\Users\tobias.weber\.m2\repository\org\springframework\spring-test\4.0.3.RELEASE\spring-test-4.0.3.RELEASE.jar;
C:\Users\tobias.weber\.m2\repository\org\springframework\spring-beans\4.0.3.RELEASE\spring-beans-4.0.3.RELEASE.jar;
C:\Users\tobias.weber\.m2\repository\org\springframework\spring-context\4.0.3.RELEASE\spring-context-4.0.3.RELEASE.jar;
C:\Users\tobias.weber\.m2\repository\joda-time\joda-time\2.9\joda-time-2.9.jar

 

Weird thing is: a lot of those dependencies are not actually used in the project (Spring 5 instead of 4, no Joda-Time, no hickory, ...), but we use Lombok which does have an annotation processor but is not listed.

I can only assume that IntelliJ generates that list by itself, and it does that because of the maven-compiler-plugin's configuration in our project's POM:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</annotationProcessorPaths>
</configuration>
</plugin>
0

annotationProcessorPaths option was added in scope of this request: https://youtrack.jetbrains.com/issue/IDEA-188940 @Tobias Weber could you please create a request at https://youtrack.jetbrains.com/issues/IDEA with a sample project if it does not work as expected? Make also sure to check with the last version from https://www.jetbrains.com/idea/download

Please try as a possible workaround to set maven.import.compiler.arguments option to false in Registry (use Help | Find Action and type 'registry').

0

@Andrey Dernov

Okay I found it. First I updated IJ, but no luck.

Then I started creating the sample project for you. I took our project that was not working and stripped it down to just the essentials: 2 pojos with Lombok annotations, 1 mapper with MapStruct, a test for the mapper and the maven-compiler-plugin dependency from above.

I was quiet happy to see that that the stripped project had the same problems as before, but then I noticed something in the maven-compiler-plugin config:

<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<dependency> <--NOOOOOOOOOOOOO
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</annotationProcessorPaths>
</configuration>

I have defined Lombok as dependency instead of path. Most likely, we just copied the Lombok bit from mvnrepository.com without changing it. On Maven reimport, IJ will pick up the list of .jars containing annotation processors with help from that config. With Lombok being defined as dependency, IJ will ignore it, as it is gathering a path list.

So IJ does exactly what is described in https://youtrack.jetbrains.com/issue/IDEA-188940 with it, we were to stupid (;

0

Looks like any maven annotation processing the plexus item is included by mistake - breaking all builds with it.

plexus-container-default-1.6.jar

Any annotation processor specified with

<annotationProcessorPaths>

and this random jar gets included breaking the build.

Any annotation processor.
0

@Mark, could you please provide a demo project or a pom.xml?

0

For the love of god will you please get this fixed already...

 

 

0

I came up with a workaround for this, though it's not ideal.

I made the annotation processor we use check for the presence of an environment variable, and if it's set to true, do nothing, I then edited by idea.sh startup script to export that environment variable.

Once you've done that for whatever reason the first time you try and build, idea deletes all the generated-sources directories, but then after that it's fine, I can build from the commandline with maven to build annotations, and build in the IDE and it just uses annotations in generated-sources without altering them.

0

Try disabling the Lombok plugin that comes with IntelliJ as that also reactivates the annotation processing.

0

Please sign in to leave a comment.