Morefreefg
06/17/2020, 1:58 PM./gradlew clean assembleDebug
3. Modify .kt files that may cause incremental compilation
What I expect: Only out-of-date files will be compiled
What I got: All files get compiled
Probable cause:
see the three screenshots of kotlin-gradle-plugin code below
1. KotlinCompile is a @CacheableTask, so gradle will store it’s @Output files to make build cache happens.
2. taskBuildDirectory is marked as @LocalState, which will be removed when the task is loaded from cache.
3. when first incremental happens, kotlin check if taskBuildDirectory exists. If not, chagedFiles will be assigned to ChangedFiles.UnKnown, which cause kotlin fallback to rebuild. It will waste a plenty of meaningless time.