Gradle: Deprecate native extraOpts method in favor of common API
This commit is contained in:
+23
-1
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationWithResources
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationWithResources
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
||||||
|
import org.jetbrains.kotlin.gradle.utils.SingleWarningPerBuild
|
||||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
@@ -52,9 +53,30 @@ class KotlinNativeCompilation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Native-specific DSL.
|
// 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())
|
fun extraOpts(vararg values: Any) = extraOpts(values.toList())
|
||||||
|
|
||||||
|
@Deprecated("Use kotlinOptions.freeCompilerArgs instead", ReplaceWith("kotlinOptions.freeCompilerArgs"))
|
||||||
|
@Suppress("Deprecation")
|
||||||
fun extraOpts(values: List<Any>) {
|
fun extraOpts(values: List<Any>) {
|
||||||
extraOpts.addAll(values.map { it.toString() })
|
extraOpts.addAll(values.map { it.toString() })
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -131,9 +131,8 @@ abstract class AbstractKotlinNativeCompile : AbstractCompile(), KotlinCompile<Ko
|
|||||||
val target: String
|
val target: String
|
||||||
@Input get() = compilation.target.konanTarget.name
|
@Input get() = compilation.target.konanTarget.name
|
||||||
|
|
||||||
// TODO: rework.
|
|
||||||
val additionalCompilerOptions: Collection<String>
|
val additionalCompilerOptions: Collection<String>
|
||||||
@Input get() = compilation.extraOpts
|
@Input get() = kotlinOptions.freeCompilerArgs
|
||||||
|
|
||||||
// region Language settings imported from a SourceSet.
|
// region Language settings imported from a SourceSet.
|
||||||
val languageSettings: LanguageSettingsBuilder?
|
val languageSettings: LanguageSettingsBuilder?
|
||||||
@@ -169,12 +168,12 @@ abstract class AbstractKotlinNativeCompile : AbstractCompile(), KotlinCompile<Ko
|
|||||||
override var suppressWarnings: Boolean = false
|
override var suppressWarnings: Boolean = false
|
||||||
override var verbose: 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.
|
// Delegate for compilations's extra options.
|
||||||
override var freeCompilerArgs: List<String>
|
override var freeCompilerArgs: List<String>
|
||||||
get() = compilation.extraOpts
|
get() = compilation.extraOptsNoWarn
|
||||||
set(value) {
|
set(value) {
|
||||||
compilation.extraOpts = value.toMutableList()
|
compilation.extraOptsNoWarn = value.toMutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user