Make kotlin-android-extensions always cause a compilation error.

kotlin-android-extensions are deprecated and have been scheduled
for removal in 1.8.0.

https://android-developers.googleblog.com/2022/02/discontinuing-kotlin-synthetics-for-views.html
This commit is contained in:
Mads Ager
2022-09-14 13:41:21 +02:00
committed by Alexander Udalov
parent 7293dd6d65
commit ff84c19eff
3 changed files with 17 additions and 2 deletions
@@ -36,8 +36,8 @@ class AndroidExtensionsSubpluginIndicator @Inject internal constructor(private v
registry.register(KotlinAndroidExtensionModelBuilder())
project.plugins.apply(AndroidSubplugin::class.java)
project.logger.warn(
"Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. " +
project.logger.error(
"Error: The 'kotlin-android-extensions' Gradle plugin is no longer supported. " +
"Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start " +
"working with View Binding (https://developer.android.com/topic/libraries/view-binding) " +
"and the 'kotlin-parcelize' plugin."
@@ -20,6 +20,7 @@ dependencies {
compileOnly(project(":compiler:ir.backend.common"))
compileOnly(project(":compiler:backend.jvm"))
compileOnly(project(":compiler:ir.tree"))
compileOnly(project(":compiler:cli"))
compileOnly(project(":kotlin-android-extensions-runtime"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
@@ -30,6 +30,8 @@ import org.jetbrains.kotlin.android.synthetic.res.AndroidVariant
import org.jetbrains.kotlin.android.synthetic.res.CliAndroidLayoutXmlFileManager
import org.jetbrains.kotlin.android.synthetic.res.CliAndroidPackageFragmentProviderExtension
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
import org.jetbrains.kotlin.compiler.plugin.*
@@ -103,6 +105,16 @@ class AndroidCommandLineProcessor : CommandLineProcessor {
@Suppress("DEPRECATION")
class AndroidComponentRegistrar : ComponentRegistrar {
companion object {
fun reportRemovedError(configuration: CompilerConfiguration) {
val errorMessage =
"The Android extensions ('kotlin-android-extensions') compiler plugin is no longer supported. " +
"Please use kotlin parcelize and view binding. " +
"More information: https://goo.gle/kotlin-android-extensions-deprecation"
configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
?.report(CompilerMessageSeverity.ERROR, errorMessage, null)
?: throw IllegalStateException(errorMessage)
}
fun registerParcelExtensions(project: Project) {
ExpressionCodegenExtension.registerExtension(project, ParcelableCodegenExtension())
IrGenerationExtension.registerExtension(project, ParcelableIrGeneratorExtension())
@@ -153,6 +165,8 @@ class AndroidComponentRegistrar : ComponentRegistrar {
}
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
reportRemovedError(configuration)
val features = configuration.get(AndroidConfigurationKeys.FEATURES) ?: AndroidExtensionsFeature.values().toSet()
val isExperimental = configuration.get(AndroidConfigurationKeys.EXPERIMENTAL) == "true"