compileJava does not build incrementally

I was compiling my project and noticed that even if I change only one class file, e.g., it will recompile the whole project.
Build Scan® | Gradle Cloud Services that the build cache is not hit, and I don’t understand the real mechanism of how that cache works.
This is the build file of my project PowerNukkitX/build.gradle.kts at master · PowerNukkitX/PowerNukkitX · GitHub

Of course the build cache will not be hit, that is only for full task outputs.
So either you have the exact same inputs and can use the outputs of the task as a whole from cache, or the task needs to execute.

But Gradle does incremental Java compilation.
So if you change one file, only that files and all files using it directly or transitively will get recompiled.
For more info see: The Java Plugin

1 Like

Oh, I see you use the bloody Lombok.
As far as I remember the dirty hooking into the compiler also needs it to disable incremental Java compilation.
So iirc, you indeed need to recompile everything always for any change as long as you use Lombok.

Hm, no, it should not any longer.
Lombok disables incremental compilation in gradle · Issue #1580 · projectlombok/lombok · GitHub should be fixed since 1.16.22 and you are using 1.18.30

I also dislike lombok very much, but it’s a damn legacy and I’ve decided to delombok completely

1 Like