Load kotlin.incremental from local.properties file too
This commit is contained in:
+2
-1
@@ -53,6 +53,7 @@ const val ANNOTATIONS_PLUGIN_NAME = "org.jetbrains.kotlin.kapt"
|
||||
const val KOTLIN_BUILD_DIR_NAME = "kotlin"
|
||||
const val CACHES_DIR_NAME = "caches"
|
||||
const val DIRTY_SOURCES_FILE_NAME = "dirty-sources.txt"
|
||||
const val USING_EXPERIMENTAL_INCREMENTAL_MESSAGE = "Using experimental kotlin incremental compilation"
|
||||
|
||||
abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile() {
|
||||
abstract protected val compiler: CLICompiler<T>
|
||||
@@ -360,7 +361,7 @@ open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments>() {
|
||||
return
|
||||
}
|
||||
|
||||
logger.warn("Using experimental kotlin incremental compilation")
|
||||
logger.warn(USING_EXPERIMENTAL_INCREMENTAL_MESSAGE)
|
||||
anyClassesCompiled = false
|
||||
// TODO: decide what to do if no files are considered dirty - rebuild or skip the module
|
||||
var (sourcesToCompile, isIncrementalDecided) = calculateSourcesToCompile()
|
||||
|
||||
+18
-3
@@ -2,10 +2,16 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import java.util.*
|
||||
|
||||
fun mapKotlinTaskProperties(project: Project, task: AbstractCompile) {
|
||||
for (mapping in propertyMappings) {
|
||||
mapping.apply(project, task)
|
||||
propertyMappings.forEach { it.apply(project, task) }
|
||||
|
||||
val localPropertiesFile = project.rootProject.file("local.properties")
|
||||
if (localPropertiesFile.isFile) {
|
||||
val properties = Properties()
|
||||
properties.load(localPropertiesFile.inputStream())
|
||||
propertyMappings.forEach { it.apply(properties, task) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +27,16 @@ private class KotlinPropertyMapping<T>(
|
||||
fun apply(project: Project, task: AbstractCompile) {
|
||||
if (!project.hasProperty(projectPropName)) return
|
||||
|
||||
val value = project.property(projectPropName) as? String ?: return
|
||||
setPropertyValue(task, project.property(projectPropName))
|
||||
}
|
||||
|
||||
fun apply(properties: Properties, task: AbstractCompile) {
|
||||
setPropertyValue(task, properties.getProperty(projectPropName))
|
||||
}
|
||||
|
||||
private fun setPropertyValue(task: AbstractCompile, value: Any?) {
|
||||
if (value !is String) return
|
||||
|
||||
val transformedValue = transform(value) ?: return
|
||||
task.setProperty(taskPropName, transformedValue)
|
||||
}
|
||||
|
||||
+14
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.jetbrains.kotlin.gradle.plugin.CleanUpBuildListener
|
||||
import org.jetbrains.kotlin.gradle.tasks.USING_EXPERIMENTAL_INCREMENTAL_MESSAGE
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import kotlin.test.assertTrue
|
||||
@@ -269,4 +270,17 @@ class KotlinGradleIT: BaseGradleIT() {
|
||||
assertFileExists("build/classes/main/example/TestClassCustomized.class")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementalPropertyFromLocalPropertiesFile() {
|
||||
val project = Project("kotlinProject", "2.10")
|
||||
project.setupWorkingDir()
|
||||
|
||||
val localPropertyFile = File(project.projectDir, "local.properties")
|
||||
localPropertyFile.writeText("kotlin.incremental=true")
|
||||
|
||||
project.build("build") {
|
||||
assertContains(USING_EXPERIMENTAL_INCREMENTAL_MESSAGE)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user