What is incremental compilation? I guess incremental means, do small compilation steps after each small code change. Do as little compilation as possible (i.e. don’t compile what is not affected by the code change). Is this a good explanation? Does incremental compilation depend on the compiler or the mechanism (e.g. Gradle) calling the compiler and telling it what to do? So basically Gradle could do incremental compilation with every compiler, even javac? Or does Gradle need a special compiler and why?
First there was the magical Eclipse compiler. Without any noticeable CPU usage or delay your code was immediately executable. I think this is now possible for almost a decade. How was Eclipse doing this? I thought the ECJ was building an AST and whenever a code change took place exactly knew which classes were affected by that change. Rumor had it, that ECJ didn’t even need to compile entire class files but could just replace the code for a single method if the code change was restricted to that method. I am not sure if this is true - maybe somebody knows more?
Then there are build tools like ANT and Gradle. I always thought Gradle was doing incremental compilation even before 2.1? Is this incorrect? Was Gradle always compiling the entire project even if just a single local variable in a private class was modified? Or was it already doing something clever before 2.1, like at least checking file timestamps? Or is checking timestamps not very helpful as long as you don’t have an AST which tells you all the places where global variables etc. are used (inlined by the compiler)? Can you give a few major examples where a small change in a single class potentially affects the entire project and therefore demands compiling everything. I already mentioned global variables. What other examples are there?
Finally there is IDEA which seems to be married to Gradle eventually. IDEA has all kinds of confusing settings. First of all you can pick the Eclipse compiler, automatically make your project, run with compilation errors, etc. I think Gradle doesn’t really benefit from this, right? When using a non-Gradle setup, IDEA can use all these features and is always-ready when it comes to compilation - like Eclipse, correct? When using a Gradle project setup IDEA (I am using EAP14) still compiles its own code but also sometimes uses Gradle tasks (for example) to run a executable Class. Or is EAP14 now fully using Gradle and all the compiler settings in IDEA are not used at all? Can sombody clarify? Also: how will the future look like? Will IDEA be fully fused with Gradle or will IDEA keep doing its own separate compilation to get their own AST etc.?
I am very confused.