Move incremental compilation enabled check from CacheFormatVersion to KotlinBuilder
This commit is contained in:
@@ -134,8 +134,10 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
||||
|
||||
val dataManager = projectDescriptor.dataManager
|
||||
|
||||
if (chunk.getTargets().any { dataManager.getDataPaths().getKotlinCacheVersion(it).isIncompatible() }) {
|
||||
LOG.info("Clearing caches for " + chunk.getTargets().map { it.getPresentableName() }.join())
|
||||
if (IncrementalCompilation.ENABLED &&
|
||||
chunk.targets.any { dataManager.dataPaths.getKotlinCacheVersion(it).isIncompatible() }
|
||||
) {
|
||||
LOG.info("Clearing caches for " + chunk.targets.map { it.presentableName }.join())
|
||||
val incrementalCaches = getIncrementalCaches(chunk, context)
|
||||
incrementalCaches.values().forEach(StorageOwner::clean)
|
||||
return CHUNK_REBUILD_REQUIRED
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.jps.incremental
|
||||
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import java.io.File
|
||||
@@ -31,32 +30,30 @@ class CacheFormatVersion(targetDataRoot: File) {
|
||||
JvmAbi.VERSION.major * 1000 +
|
||||
JvmAbi.VERSION.minor
|
||||
|
||||
private val NON_INCREMENTAL_MODE_PSEUDO_VERSION = Int.MAX_VALUE
|
||||
|
||||
val FORMAT_VERSION_FILE_PATH: String = "$CACHE_DIRECTORY_NAME/format-version.txt"
|
||||
}
|
||||
|
||||
private val file = File(targetDataRoot, FORMAT_VERSION_FILE_PATH)
|
||||
|
||||
private fun actualCacheFormatVersion() = if (IncrementalCompilation.ENABLED) CACHE_FORMAT_VERSION else NON_INCREMENTAL_MODE_PSEUDO_VERSION
|
||||
|
||||
public fun isIncompatible(): Boolean {
|
||||
fun isIncompatible(): Boolean {
|
||||
if (!file.exists()) return false
|
||||
|
||||
val versionNumber = file.readText().toInt()
|
||||
val expectedVersionNumber = actualCacheFormatVersion()
|
||||
|
||||
if (versionNumber != expectedVersionNumber) {
|
||||
KotlinBuilder.LOG.info("Incompatible incremental cache version, expected $expectedVersionNumber, actual $versionNumber")
|
||||
if (versionNumber != CACHE_FORMAT_VERSION) {
|
||||
KotlinBuilder.LOG.info("Incompatible incremental cache version, expected $CACHE_FORMAT_VERSION, actual $versionNumber")
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun saveIfNeeded() {
|
||||
if (file.parentFile.exists() && !file.exists()) {
|
||||
file.writeText(actualCacheFormatVersion().toString())
|
||||
if (!file.parentFile.exists()) {
|
||||
file.parentFile.mkdirs()
|
||||
}
|
||||
|
||||
file.writeText("$CACHE_FORMAT_VERSION")
|
||||
}
|
||||
|
||||
fun clean() {
|
||||
|
||||
Reference in New Issue
Block a user