More details about the compilation since recompilation trigger is not clear
Hi,
I am coming to you since I have a problem that causes extended (re)builds on very small code changes: if I only add a field in a single class the entire module is mark for recompilation and I don't know how to figure out what could be the cause. I think it's Lombok but it's purely a guess only and I need some better pointer.
I am running latest EAP build of IJ, but this is reproducible on the stable branch as well
I would like to get some kind of information how I can debug the cause of the recompilation issue as shown below:
Executing pre-compile tasks...
Running 'before' tasks
Checking sources
Copying resources... [x-api]
Copying resources... [x-basics-util]
Parsing java… [x-api]
Writing classes… [x-api]
Checking dependencies… [x-api]
Marking x-api and direct dependants for recompilation. <---- WHY???
Adding nullability assertions… [x-api]
Adding pattern assertions… [x-api]
Updating dependency information… [x-api]
Parsing java… [tests of x-api]
Writing classes… [tests of x-api]
Updating dependency information… [tests of x-api]
Adding nullability assertions… [tests of x-api]
Adding pattern assertions… [tests of x-api]
Running 'after' tasks
javac 17.0.3 was used to compile java sources
Finished, saving caches…
Executing post-compile tasks...
Synchronizing output directories...
31/10/2022, 09:22 - Build completed successfully in 23 sec, 822 ms
We have some custom annotation processors and we also use Lombok. So, I would really like to find the cause of the trigger - is it caused by output of one of these annotation processors or not. It could be very technical, I will try to figure it out myself, I just need a pointer to the right direction.
Thank you
请先登录再写评论。
Hi Milan,
Do you run Build > Recompile 'class name' to trigger recompilation?
See if it helps to disable the following setting (documentation):
Hi Arina,
I have found out that having that option turned on or off doesn't influence my particular case - it doesn't help me debug the issue nor does it trigger the "recompilation" less often: the output of the command "Build module" is the same
Kind Regards
For context, the difference between recompilation is 1sec vs >20sec, only because of a very small change (adding a field in one of the leaf classes - not a root of a huge hierarchy or anything like that).
That's why I'd like to understand the cause first, otherwise it's just unclear to me why would the entire module be recompiled, it seems a bit off to me
Thanks Milan.
Is recompilation triggered on its own after changes to the file are made? Or do you run or debug the code first, and see the compilation output as a result?
Hi Arina,
So, what I have is a module of 500 Java files.
To bootstrap and make everything clean for reproduction I do the following steps:
There is something in my build setup that triggers recompilation in 4) which I wouldn't expect.
So, how can I figure out what is triggering that "Marked ... for recompilation"?
KR, Milan
Thank you Milan.
The issue may be caused by the annotation processor indeed. I see a similar issue was reported a while ago for a Micronaut project: https://youtrack.jetbrains.com/issue/IDEA-262041
Do you use Maven or Gradle as a build system in your project?
Would it be possible for you to try and create a small demo project where this can be reproduced? If not, please attach the entire archive with logs generated via Help | Collect Logs and Diagnostics Data.
Hi Milan,
You can also enable additional logging for the build.log file to see verbose explanations of why the entire module was marked for compilation.
To do so, go to the <IDE system dir>/log/build-log directory, find the file called build-log*.properties, open it and uncomment the last two lines (also a restart of the IDE may be required):
After the issue is reproduced, you can attach the resulting buld.log file to IDEA-262041. Developers will take a look at it and reply.
I found the culprit, it's that one of my annotation processors is creating a source file that takes the build iteration out of the incremental mode into non-incremental. It is noted like that in the build logs with the message
Exactly the same as https://youtrack.jetbrains.com/issue/IDEA-262041. There's actually no need for me to do anything else since it's exactly like that issue :) I will just subscribe to it to see if/how/when it gets fixed.
Thank you Arina, you helped a lot to drive this to an ongoing / already reported issue!
Happy to help Milan👍
Developers assigned to IDEA-262041 have just confirmed to me they are working on a fix, so hopefully the problem will cease to exist very soon.
Hi Milan,
Just an update to let you know the fix will be included into version 2023.1 (ETA: beginning of next year). We can also backport it to version 2022.3 (ETA: end of November) if needed.