Add more robust check for plugin application order (KT-37245)

Cause build to fail if the 'kotlin-kapt' plugin is applied before the
  main Kotlin plugin ('kotlin' or 'kotlin-android').
  The 'logger.error()' prints an error message, however the build
  continues.
This commit is contained in:
Yan Zhulanow
2020-03-12 21:28:54 +09:00
parent 0247a300d1
commit 897c48f97e
@@ -9,6 +9,7 @@ import com.android.build.gradle.BaseExtension
import com.android.build.gradle.api.AndroidSourceSet
import com.android.builder.model.SourceProvider
import com.intellij.openapi.util.SystemInfo
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
@@ -65,7 +66,7 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
project.getKotlinPluginVersion()?.let { kotlinPluginVersion ->
val kaptDependency = getPluginArtifact().run { "$groupId:$artifactId:$kotlinPluginVersion" }
dependencies.add(project.dependencies.create(kaptDependency))
} ?: project.logger.error("Kotlin plugin should be enabled before 'kotlin-kapt'")
} ?: throw GradleException("Kotlin plugin should be enabled before 'kotlin-kapt'")
}
}
registry.register(KaptModelBuilder())