Mark compiler arguments that should generate deprecated kotlinOptions DSL
This will allow to keep backward compatiblity for deprecated kotlinOptions DSL for already existing compiler arguments, but add a new one only into compilerOptions DSL. ^KT-53108 In Progress
This commit is contained in:
committed by
Space Team
parent
671aa68ad6
commit
43eea47032
+6
-3
@@ -33,7 +33,8 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.LANGUAGE_VERSIONS,
|
value = DefaultValue.LANGUAGE_VERSIONS,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-language-version",
|
value = "-language-version",
|
||||||
@@ -47,7 +48,8 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.API_VERSIONS,
|
value = DefaultValue.API_VERSIONS,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-api-version",
|
value = "-api-version",
|
||||||
@@ -298,7 +300,8 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-Xuse-k2",
|
value = "-Xuse-k2",
|
||||||
|
|||||||
+6
-3
@@ -40,21 +40,24 @@ abstract class CommonToolArguments : Freezable(), Serializable {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INTERNAL
|
gradleInputType = GradleInputTypes.INTERNAL,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-verbose", description = "Enable verbose logging output")
|
@Argument(value = "-verbose", description = "Enable verbose logging output")
|
||||||
var verbose: Boolean by FreezableVar(false)
|
var verbose: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INTERNAL
|
gradleInputType = GradleInputTypes.INTERNAL,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-nowarn", description = "Generate no warnings")
|
@Argument(value = "-nowarn", description = "Generate no warnings")
|
||||||
var suppressWarnings: Boolean by FreezableVar(false)
|
var suppressWarnings: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-Werror", description = "Report an error if there are any warnings")
|
@Argument(value = "-Werror", description = "Report an error if there are any warnings")
|
||||||
var allWarningsAsErrors: Boolean by FreezableVar(false)
|
var allWarningsAsErrors: Boolean by FreezableVar(false)
|
||||||
|
|||||||
+2
-1
@@ -26,7 +26,8 @@ import kotlin.reflect.KVisibility
|
|||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
annotation class GradleOption(
|
annotation class GradleOption(
|
||||||
val value: Int,
|
val value: Int,
|
||||||
val gradleInputType: String
|
val gradleInputType: String,
|
||||||
|
val shouldGenerateDeprecatedKotlinOptions: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum class here is not possible due to bug in K2 compiler:
|
// Enum class here is not possible due to bug in K2 compiler:
|
||||||
|
|||||||
+26
-13
@@ -19,7 +19,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INTERNAL // handled by task 'outputFileProperty'
|
gradleInputType = GradleInputTypes.INTERNAL, // handled by task 'outputFileProperty'
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@GradleDeprecatedOption(
|
@GradleDeprecatedOption(
|
||||||
message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName",
|
message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName",
|
||||||
@@ -34,14 +35,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-ir-output-name", description = "Base name of generated files")
|
@Argument(value = "-ir-output-name", description = "Base name of generated files")
|
||||||
var moduleName: String? by NullableStringFreezableVar(null)
|
var moduleName: String? by NullableStringFreezableVar(null)
|
||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-no-stdlib", description = "Don't automatically include the default Kotlin/JS stdlib into compilation dependencies")
|
@Argument(value = "-no-stdlib", description = "Don't automatically include the default Kotlin/JS stdlib into compilation dependencies")
|
||||||
var noStdlib: Boolean by FreezableVar(false)
|
var noStdlib: Boolean by FreezableVar(false)
|
||||||
@@ -62,14 +65,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-source-map", description = "Generate source map")
|
@Argument(value = "-source-map", description = "Generate source map")
|
||||||
var sourceMap: Boolean by FreezableVar(false)
|
var sourceMap: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-source-map-prefix", description = "Add the specified prefix to paths in the source map")
|
@Argument(value = "-source-map-prefix", description = "Add the specified prefix to paths in the source map")
|
||||||
var sourceMapPrefix: String? by NullableStringFreezableVar(null)
|
var sourceMapPrefix: String? by NullableStringFreezableVar(null)
|
||||||
@@ -88,7 +93,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
*/
|
*/
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.JS_SOURCE_MAP_CONTENT_MODES,
|
value = DefaultValue.JS_SOURCE_MAP_CONTENT_MODES,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-source-map-embed-sources",
|
value = "-source-map-embed-sources",
|
||||||
@@ -99,7 +105,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.JS_SOURCE_MAP_NAMES_POLICY,
|
value = DefaultValue.JS_SOURCE_MAP_NAMES_POLICY,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-source-map-names-policy",
|
value = "-source-map-names-policy",
|
||||||
@@ -110,14 +117,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-meta-info", description = "Generate .meta.js and .kjsm files with metadata. Use to create a library")
|
@Argument(value = "-meta-info", description = "Generate .meta.js and .kjsm files with metadata. Use to create a library")
|
||||||
var metaInfo: Boolean by FreezableVar(false)
|
var metaInfo: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.JS_ECMA_VERSIONS,
|
value = DefaultValue.JS_ECMA_VERSIONS,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-target", valueDescription = "{ v5 }", description = "Generate JS files for specific ECMA version")
|
@Argument(value = "-target", valueDescription = "{ v5 }", description = "Generate JS files for specific ECMA version")
|
||||||
var target: String? by NullableStringFreezableVar(null)
|
var target: String? by NullableStringFreezableVar(null)
|
||||||
@@ -131,7 +140,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.JS_MODULE_KINDS,
|
value = DefaultValue.JS_MODULE_KINDS,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-module-kind",
|
value = "-module-kind",
|
||||||
@@ -142,7 +152,8 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.JS_MAIN,
|
value = DefaultValue.JS_MAIN,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-main",
|
value = "-main",
|
||||||
@@ -282,14 +293,16 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-Xtyped-arrays", description = "Translate primitive arrays to JS typed arrays")
|
@Argument(value = "-Xtyped-arrays", description = "Translate primitive arrays to JS typed arrays")
|
||||||
var typedArrays: Boolean by FreezableVar(true)
|
var typedArrays: Boolean by FreezableVar(true)
|
||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-Xfriend-modules-disabled", description = "Disable internal declaration export")
|
@Argument(value = "-Xfriend-modules-disabled", description = "Disable internal declaration export")
|
||||||
var friendModulesDisabled: Boolean by FreezableVar(false)
|
var friendModulesDisabled: Boolean by FreezableVar(false)
|
||||||
|
|||||||
+4
-2
@@ -15,7 +15,8 @@ class K2JSDceArguments : CommonToolArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INTERNAL // handled by 'destinationDirectory'
|
gradleInputType = GradleInputTypes.INTERNAL, // handled by 'destinationDirectory'
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@GradleDeprecatedOption(
|
@GradleDeprecatedOption(
|
||||||
message = "Use task 'destinationDirectory' to configure output directory",
|
message = "Use task 'destinationDirectory' to configure output directory",
|
||||||
@@ -44,7 +45,8 @@ class K2JSDceArguments : CommonToolArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-dev-mode",
|
value = "-dev-mode",
|
||||||
|
|||||||
+8
-4
@@ -38,7 +38,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime into the classpath")
|
@Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime into the classpath")
|
||||||
var noJdk: Boolean by FreezableVar(false)
|
var noJdk: Boolean by FreezableVar(false)
|
||||||
@@ -68,14 +69,16 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-module-name", valueDescription = "<name>", description = "Name of the generated .kotlin_module file")
|
@Argument(value = "-module-name", valueDescription = "<name>", description = "Name of the generated .kotlin_module file")
|
||||||
var moduleName: String? by NullableStringFreezableVar(null)
|
var moduleName: String? by NullableStringFreezableVar(null)
|
||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.JVM_TARGET_VERSIONS,
|
value = DefaultValue.JVM_TARGET_VERSIONS,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-jvm-target",
|
value = "-jvm-target",
|
||||||
@@ -86,7 +89,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "-java-parameters", description = "Generate metadata for Java 1.8 reflection on method parameters")
|
@Argument(value = "-java-parameters", description = "Generate metadata for Java 1.8 reflection on method parameters")
|
||||||
var javaParameters: Boolean by FreezableVar(false)
|
var javaParameters: Boolean by FreezableVar(false)
|
||||||
|
|||||||
+15
-6
@@ -22,7 +22,8 @@ import kotlin.reflect.full.withNullability
|
|||||||
interface AdditionalGradleProperties {
|
interface AdditionalGradleProperties {
|
||||||
@GradleOption(
|
@GradleOption(
|
||||||
value = DefaultValue.EMPTY_STRING_LIST_DEFAULT,
|
value = DefaultValue.EMPTY_STRING_LIST_DEFAULT,
|
||||||
gradleInputType = GradleInputTypes.INPUT
|
gradleInputType = GradleInputTypes.INPUT,
|
||||||
|
shouldGenerateDeprecatedKotlinOptions = true,
|
||||||
)
|
)
|
||||||
@Argument(value = "", description = "A list of additional compiler arguments")
|
@Argument(value = "", description = "A list of additional compiler arguments")
|
||||||
var freeCompilerArgs: List<String>
|
var freeCompilerArgs: List<String>
|
||||||
@@ -488,12 +489,17 @@ private fun Printer.generateDeprecatedInterface(
|
|||||||
val modifier = """
|
val modifier = """
|
||||||
interface
|
interface
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
generateDeclaration(modifier, type, afterType = afterType) {
|
val deprecatedProperties = properties.filter { it.generateDeprecatedKotlinOption }
|
||||||
|
// KotlinMultiplatformCommonOptions doesn't have any options, but it is being kept for backward compatibility
|
||||||
|
if (deprecatedProperties.isNotEmpty() || type.asString().endsWith("KotlinMultiplatformCommonOptions")) {
|
||||||
|
generateDeclaration(modifier, type, afterType = afterType) {
|
||||||
|
|
||||||
println("${if (parentType != null) "override " else ""}val options: $compilerOptionType")
|
println("${if (parentType != null) "override " else ""}val options: $compilerOptionType")
|
||||||
properties.forEach {
|
deprecatedProperties
|
||||||
println()
|
.forEach {
|
||||||
generatePropertyGetterAndSetter(it)
|
println()
|
||||||
|
generatePropertyGetterAndSetter(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -790,6 +796,9 @@ private val KProperty1<*, *>.gradleLazyReturnTypeInstantiator: String
|
|||||||
private val KProperty1<*, *>.gradleInputType: String get() =
|
private val KProperty1<*, *>.gradleInputType: String get() =
|
||||||
findAnnotation<GradleOption>()!!.gradleInputType
|
findAnnotation<GradleOption>()!!.gradleInputType
|
||||||
|
|
||||||
|
private val KProperty1<*, *>.generateDeprecatedKotlinOption: Boolean
|
||||||
|
get() = findAnnotation<GradleOption>()!!.shouldGenerateDeprecatedKotlinOptions
|
||||||
|
|
||||||
private inline fun <reified T> KAnnotatedElement.findAnnotation(): T? =
|
private inline fun <reified T> KAnnotatedElement.findAnnotation(): T? =
|
||||||
annotations.filterIsInstance<T>().firstOrNull()
|
annotations.filterIsInstance<T>().firstOrNull()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user