Kotlin Gradle Plugin: Provide serialized list of compiler arguments in compilation tasks

This commit is contained in:
Alexey Sedunov
2017-01-25 14:12:35 +03:00
parent bb54f23472
commit dafb6f8b3c
2 changed files with 13 additions and 2 deletions
@@ -19,7 +19,11 @@ package org.jetbrains.kotlin.gradle.dsl
import groovy.lang.Closure
import org.gradle.api.Task
interface KotlinCompile<T : KotlinCommonOptions> : Task {
interface CompilerArgumentAware {
val serializedCompilerArguments: List<String>
}
interface KotlinCompile<T : KotlinCommonOptions> : Task, CompilerArgumentAware {
val kotlinOptions: T
fun kotlinOptions(fn: T.() -> Unit) {
@@ -52,9 +52,16 @@ const val ANNOTATIONS_PLUGIN_NAME = "org.jetbrains.kotlin.kapt"
const val KOTLIN_BUILD_DIR_NAME = "kotlin"
const val USING_EXPERIMENTAL_INCREMENTAL_MESSAGE = "Using experimental kotlin incremental compilation"
abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile() {
abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile(), CompilerArgumentAware {
abstract protected fun populateCompilerArguments(): T
override val serializedCompilerArguments: List<String>
get() {
val arguments = populateCompilerArguments()
arguments.setupCommonCompilerArgs()
return ArgumentUtils.convertArgumentsToStringList(arguments)
}
// 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