Remove custom cache version checks from Gradle

#KT-21009 fixed

Cache version could be changed only when compiler is changed.

@InputFiles on `AbstractKotlinCompileTool#computedCompilerClasspath`
ensures that non incremental build is performed when compiler is changed.
This commit is contained in:
Alexey Tsvetkov
2017-11-23 15:03:29 +03:00
parent 602ac3e816
commit 0077ab59d6
3 changed files with 0 additions and 67 deletions
@@ -1,53 +0,0 @@
package org.jetbrains.kotlin.gradle
import org.junit.Test
import java.io.File
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
class CacheVersionChangedIT : BaseGradleIT() {
@Test
fun testGradleCacheVersionChanged() {
compileIncrementallyWithChangedVersion("gradle-format-version.txt")
}
@Test
fun testNormalCacheVersionChanged() {
compileIncrementallyWithChangedVersion("format-version.txt")
}
@Test
fun testDataContainerCacheVersionChanged() {
compileIncrementallyWithChangedVersion("data-container-format-version.txt")
}
private fun compileIncrementallyWithChangedVersion(versionFileName: String) {
val project = Project("kotlinProject", "2.10")
val options = defaultBuildOptions().copy(incremental = true)
fun File.projectPath() = relativeTo(project.projectDir).path
project.build("build", options = options) {
assertSuccessful()
}
val versionFile = File(project.projectDir, "build/kotlin/compileKotlin/$versionFileName")
assertTrue(versionFile.exists(), "${versionFile.projectPath()} does not exist!")
val modifiedVersion = "777"
versionFile.writeText(modifiedVersion)
project.build("build", options = options) {
assertSuccessful()
assertNotEquals(modifiedVersion, versionFile.readText(), "${versionFile.projectPath()} was not rewritten by build")
val mainDir = File(project.projectDir, "src/main")
val mainKotlinFiles = mainDir.walk().filter { it.isFile && it.extension.equals("kt", ignoreCase = true) }
val mainKotlinRelativePaths = mainKotlinFiles.map(File::projectPath).toList()
assertCompiledKotlinSources(mainKotlinRelativePaths)
}
project.build("build", options = options) {
assertSuccessful()
assertCompiledKotlinSources(listOf(), weakTesting = false)
}
}
}
@@ -77,12 +77,6 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
internal val taskBuildDirectory: File
get() = File(File(project.buildDir, KOTLIN_BUILD_DIR_NAME), name).apply { mkdirs() }
private val cacheVersions: List<CacheVersion>
get() =
listOf(normalCacheVersion(taskBuildDirectory, enabled = incremental),
dataContainerCacheVersion(taskBuildDirectory, enabled = incremental),
gradleCacheVersion(taskBuildDirectory, enabled = incremental))
// indicates that task should compile kotlin incrementally if possible
// it's not possible when IncrementalTaskInputs#isIncremental returns false (i.e first build)
var incremental: Boolean = false
@@ -92,13 +86,6 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
logger.kotlinDebug { "Set $this.incremental=$value" }
}
internal val isCacheFormatUpToDate: Boolean
get() {
if (!incremental) return true
return cacheVersions.all { it.checkVersion() == CacheVersion.Action.DO_NOTHING }
}
abstract protected fun createCompilerArgs(): T
internal val pluginOptions = CompilerPluginOptions()
@@ -41,7 +41,6 @@ internal open class KotlinTasksProvider {
this.sourceSetName = sourceSetName
this.friendTaskName = taskToFriendTaskMapper[this]
mapKotlinTaskProperties(project, this)
outputs.upToDateWhen { isCacheFormatUpToDate }
}
protected open val taskToFriendTaskMapper: TaskToFriendTaskMapper =