Incremental Java Compile has been very temperamental

Hi,

I have a Spring Project with about 3500 files. 99% of the files are currently generated off a third party codegen library JOOQ. When I change in the remaining 1% of the files it sometimes does a full javaCompile and sometimes does incremental build - as if it has a mind of its own.

When it does a full compile for small code changes during the change -> build -> run cycle is it very disruptive as full build takes over 5 minutes. Every second or third recompile this happens.

I have this entry in gradle.build:
tasks.withType(JavaCompile) {
//enable compilation in a separate daemon process
options.fork = true

//enable incremental compilation
options.incremental = true
}

And this is what gradle.properties looks like:
org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_181
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

How can this be fixed?

You’re probably changing a file with a public constant, which requires a full recompile because constants can be inlined anywhere, so our bytecode analysis can’t reliably detect who uses them. Avoid public constants and use static methods instead.

Setting up build caching in the gradle.properties file seems to have made it a lot better.

Caching and incremental compile are completely unrelated. The only thing that caching would improve is if you go back and forth between branches a lot or you do changes and then undo them again. Caching doesn’t help with incremental changes.

Ok, magically the issue stopped immediately after I updated the gradle.build file, unsure then of what it may have been.

Thanks for the feedback.