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