Incremental Java Compile has been very temperamental

(Asif Rahman) #1


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
tasks.withType(JavaCompile) {
//enable compilation in a separate daemon process
options.fork = true

//enable incremental compilation
options.incremental = true

And this is what looks like:\Program Files\Java\jdk1.8.0_181
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

How can this be fixed?

(Stefan Oehme) #2

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.

(Asif Rahman) #3

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

(Stefan Oehme) #4

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.

(Asif Rahman) #5

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

Thanks for the feedback.