[Gradle] Add Gradle & task property to set compiler execution strategy
#KT-49299 Fixed
This commit is contained in:
committed by
Space
parent
b4cb7f3610
commit
e9c8135dfa
+46
@@ -7,8 +7,48 @@ package org.jetbrains.kotlin.gradle.tasks
|
||||
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Internal
|
||||
|
||||
enum class KotlinCompilerExecutionStrategy(
|
||||
/**
|
||||
* Value that should be passed for `kotlin.compiler.execution.strategy` Gradle or system property to choose the strategy
|
||||
*/
|
||||
val propertyValue: String
|
||||
) {
|
||||
/**
|
||||
* Execute Kotlin compiler in its own daemon. Default strategy.
|
||||
*
|
||||
* Daemon may be shared across multiple compile tasks if it's considered compatible
|
||||
*/
|
||||
DAEMON("daemon"),
|
||||
|
||||
/**
|
||||
* Execute Kotlin compiler inside the Gradle process
|
||||
*
|
||||
* Note: currently this strategy doesn't support incremental compilation
|
||||
*/
|
||||
IN_PROCESS("in-process"),
|
||||
|
||||
/**
|
||||
* Execute Kotlin compiler in a new forked process for each compilation
|
||||
*
|
||||
* Note: currently this strategy doesn't support incremental compilation
|
||||
*/
|
||||
OUT_OF_PROCESS("out-of-process"),
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromProperty(value: String?) =
|
||||
if (value == null) {
|
||||
DAEMON
|
||||
} else {
|
||||
values().find { it.propertyValue.equals(value, ignoreCase = true) }
|
||||
?: error("Unknown value '$value' is passed for Kotlin compiler execution strategy")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task is using Kotlin daemon to run compilation.
|
||||
*/
|
||||
@@ -18,4 +58,10 @@ interface CompileUsingKotlinDaemon : Task {
|
||||
*/
|
||||
@get:Internal
|
||||
val kotlinDaemonJvmArguments: ListProperty<String>
|
||||
|
||||
/**
|
||||
* Defines compiler execution strategy, see docs for [KotlinCompilerExecutionStrategy] for more details
|
||||
*/
|
||||
@get:Internal
|
||||
val compilerExecutionStrategy: Property<KotlinCompilerExecutionStrategy>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user