JPS: Fix updating cache format version for rebuilt targets by removing i/o optimization

Problem: previously, format-version.txt file was deleted while cleaning
target output on rebuild. Since directory was deleted, cache
attributesDiff stored in memory was not updated. This causes that on
saveExpectedStateIfNeeded does nothing.

The right way to fix it is move cache version format diff into
AbstractIncrementalCache, and override `clean()` method. But this is
hard to do for lookup storage, since used compilers set (jvm/js) will
known only after context init. This can be done by moving `expected`
attributes out of manager, but this is huge change for small benefit.

So, the optimal way for now is to write version for each build, even if
it is not changed.

#KT-27044 Fixed
This commit is contained in:
Sergey Rostov
2018-10-15 12:26:21 +03:00
parent cf31e4d58c
commit 5232f080d6
7 changed files with 11 additions and 33 deletions
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.parsing.classesFqNames
import org.jetbrains.kotlin.incremental.storage.version.CacheVersionManager
import org.jetbrains.kotlin.incremental.storage.version.saveIfNeeded
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
import java.io.File
@@ -272,7 +271,7 @@ abstract class IncrementalCompilerRunner<
processChangesAfterBuild(compilationMode, currentBuildInfo, dirtyData)
if (exitCode == ExitCode.OK) {
cachesVersionManagers.forEach { it.saveIfNeeded() }
cachesVersionManagers.forEach { it.writeVersion() }
}
return exitCode