Turn off IC for multiplatform projects by default
Multiplatform IC is enabled when a corresponding platform property is enabled and 'kotlin.incremental.multiplatform' is set to `true`. See KT-20840
This commit is contained in:
+37
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.gradle
|
||||
import org.jetbrains.kotlin.gradle.plugin.EXPECTED_BY_CONFIG_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.IMPLEMENT_CONFIG_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.IMPLEMENT_DEPRECATION_WARNING
|
||||
import org.jetbrains.kotlin.gradle.util.allKotlinFiles
|
||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
@@ -121,4 +123,39 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNonIncrementalCompileByDefault(): Unit = Project("multiplatformProject", GRADLE_VERSION).run {
|
||||
val compileCommonTask = ":lib:compileKotlinCommon"
|
||||
val compileJsTask = ":libJs:compileKotlin2Js"
|
||||
val compileJvmTask = ":libJvm:compileKotlin"
|
||||
val allKotlinTasks = listOf(compileCommonTask, compileJsTask, compileJvmTask)
|
||||
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
val commonProjectDir = File(projectDir, "lib")
|
||||
commonProjectDir.getFileByName("PlatformClass.kt").modify { it + "\n" }
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(allKotlinTasks)
|
||||
}
|
||||
|
||||
val jvmProjectDir = File(projectDir, "libJvm")
|
||||
jvmProjectDir.getFileByName("PlatformClass.kt").modify { it + "\n" }
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(listOf(compileJvmTask))
|
||||
assertTasksUpToDate(listOf(compileCommonTask, compileJsTask))
|
||||
}
|
||||
|
||||
val jsProjectDir = File(projectDir, "libJs")
|
||||
jsProjectDir.getFileByName("PlatformClass.kt").modify { it + "\n" }
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(listOf(compileJsTask))
|
||||
assertTasksUpToDate(listOf(compileCommonTask, compileJvmTask))
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -81,6 +81,16 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val incrementalMultiplatform = PropertiesProvider(project).incrementalMultiplatform ?: false
|
||||
project.afterEvaluate {
|
||||
project.tasks.withType(AbstractKotlinCompile::class.java).all {
|
||||
if (it.incremental && !incrementalMultiplatform) {
|
||||
project.logger.debug("IC is turned off for task '${it.path}' because multiplatform IC is not enabled")
|
||||
}
|
||||
it.incremental = it.incremental && incrementalMultiplatform
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var implementConfigurationIsUsed = false
|
||||
|
||||
+24
-15
@@ -25,27 +25,21 @@ import java.util.*
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
|
||||
fun mapKotlinTaskProperties(project: Project, task: AbstractKotlinCompile<*>) {
|
||||
val properties = PropertiesProvider(project)
|
||||
PropertiesProvider(project).apply {
|
||||
coroutines?.let { task.coroutinesFromGradleProperties = it }
|
||||
|
||||
properties["kotlin.coroutines"]?.let {
|
||||
task.coroutinesFromGradleProperties = Coroutines.byCompilerArgument(it)
|
||||
}
|
||||
|
||||
if (task is KotlinCompile) {
|
||||
properties["kotlin.incremental"]?.let {
|
||||
task.incremental = it.toBoolean()
|
||||
if (task is KotlinCompile) {
|
||||
incrementalJvm?.let { task.incremental = it }
|
||||
}
|
||||
}
|
||||
|
||||
if (task is Kotlin2JsCompile) {
|
||||
properties["kotlin.incremental.js"]?.let {
|
||||
task.incremental = it.toBoolean()
|
||||
if (task is Kotlin2JsCompile) {
|
||||
incrementalJs?.let { task.incremental = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PropertiesProvider(private val project: Project) {
|
||||
val localProperties = Properties()
|
||||
internal class PropertiesProvider(private val project: Project) {
|
||||
private val localProperties = Properties()
|
||||
|
||||
init {
|
||||
val localPropertiesFile = project.rootProject.file("local.properties")
|
||||
@@ -56,7 +50,22 @@ private class PropertiesProvider(private val project: Project) {
|
||||
}
|
||||
}
|
||||
|
||||
operator fun get(propName: String): String? =
|
||||
val coroutines: Coroutines?
|
||||
get() = property("kotlin.coroutines")?.let { Coroutines.byCompilerArgument(it) }
|
||||
|
||||
val incrementalJvm: Boolean?
|
||||
get() = booleanProperty("kotlin.incremental")
|
||||
|
||||
val incrementalJs: Boolean?
|
||||
get() = booleanProperty("kotlin.incremental.js")
|
||||
|
||||
val incrementalMultiplatform: Boolean?
|
||||
get() = booleanProperty("kotlin.incremental.multiplatform")
|
||||
|
||||
private fun booleanProperty(propName: String): Boolean? =
|
||||
property(propName)?.toBoolean()
|
||||
|
||||
private fun property(propName: String): String? =
|
||||
if (project.hasProperty(propName)) {
|
||||
project.property(propName) as? String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user