Gradle: Deprecate native extraOpts method in favor of common API

This commit is contained in:
Ilya Matveev
2019-08-14 19:51:58 +07:00
parent f01420332f
commit 3a935402a4
2 changed files with 27 additions and 6 deletions
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationWithResources
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
import org.jetbrains.kotlin.gradle.utils.SingleWarningPerBuild
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
import java.util.concurrent.Callable
@@ -52,9 +53,30 @@ class KotlinNativeCompilation(
}
// Native-specific DSL.
var extraOpts = mutableListOf<String>()
private fun showDeprecationWarning() = SingleWarningPerBuild.show(
project,
"The compilation.extraOpts method used in this build is deprecated. Use compilation.kotlinOptions.freeCompilerArgs instead."
)
internal var extraOptsNoWarn: MutableList<String> = mutableListOf()
@Deprecated("Use kotlinOptions.freeCompilerArgs instead", ReplaceWith("kotlinOptions.freeCompilerArgs"))
var extraOpts: MutableList<String>
get() {
showDeprecationWarning()
return extraOptsNoWarn
}
set(value) {
showDeprecationWarning()
extraOptsNoWarn = value
}
@Deprecated("Use kotlinOptions.freeCompilerArgs instead", ReplaceWith("kotlinOptions.freeCompilerArgs"))
@Suppress("Deprecation")
fun extraOpts(vararg values: Any) = extraOpts(values.toList())
@Deprecated("Use kotlinOptions.freeCompilerArgs instead", ReplaceWith("kotlinOptions.freeCompilerArgs"))
@Suppress("Deprecation")
fun extraOpts(values: List<Any>) {
extraOpts.addAll(values.map { it.toString() })
}
@@ -131,9 +131,8 @@ abstract class AbstractKotlinNativeCompile : AbstractCompile(), KotlinCompile<Ko
val target: String
@Input get() = compilation.target.konanTarget.name
// TODO: rework.
val additionalCompilerOptions: Collection<String>
@Input get() = compilation.extraOpts
@Input get() = kotlinOptions.freeCompilerArgs
// region Language settings imported from a SourceSet.
val languageSettings: LanguageSettingsBuilder?
@@ -169,12 +168,12 @@ abstract class AbstractKotlinNativeCompile : AbstractCompile(), KotlinCompile<Ko
override var suppressWarnings: Boolean = false
override var verbose: Boolean = false
// TODO: deprecate extraOptions because now we have a uniform way to access these parameters.
// TODO: Drop extraOpts in 1.3.70 and create a list here directly
// Delegate for compilations's extra options.
override var freeCompilerArgs: List<String>
get() = compilation.extraOpts
get() = compilation.extraOptsNoWarn
set(value) {
compilation.extraOpts = value.toMutableList()
compilation.extraOptsNoWarn = value.toMutableList()
}
}