Fixup for the fix of KT-39809
In the original fix for KT-39809, the Kapt plugin was not given a proper empty implementation stub: it was added to `Kapt3GradleSubplugin`, while originally the Kapt subplugin's META-INF/services entry pointed to `Kapt3KotlinGradleSubplugin`. This commit makes the correct class implement the legacy interface. Issue #KT-39809 Fixed
This commit is contained in:
+11
-3
@@ -5,8 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.util.AGPVersion
|
||||||
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
|
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
|
||||||
import org.jetbrains.kotlin.gradle.util.modify
|
import org.jetbrains.kotlin.gradle.util.modify
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
@@ -193,10 +195,10 @@ class SubpluginsIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testKotlinVersionDowngradeInSupbrojectKt39809() = with(Project("multiprojectWithDependency")) {
|
fun testKotlinVersionDowngradeInSupbrojectKt39809() = with(Project("android-dagger", directoryPrefix = "kapt2")) {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
|
|
||||||
projectDir.resolve("projA/build.gradle").modify {
|
gradleBuildScript("app").modify {
|
||||||
"""
|
"""
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
@@ -210,7 +212,13 @@ class SubpluginsIT : BaseGradleIT() {
|
|||||||
$it
|
$it
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
build(":projA:compileKotlin") {
|
build(
|
||||||
|
":app:compileDebugKotlin",
|
||||||
|
options = defaultBuildOptions().copy(
|
||||||
|
androidGradlePluginVersion = AGPVersion.v3_4_1,
|
||||||
|
androidHome = KotlinTestUtils.findAndroidSdk()
|
||||||
|
)
|
||||||
|
) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-18
@@ -43,9 +43,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
// apply plugin: 'kotlin-kapt'
|
// apply plugin: 'kotlin-kapt'
|
||||||
class Kapt3GradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
|
class Kapt3GradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
|
||||||
KotlinCompilerPluginSupportPlugin,
|
KotlinCompilerPluginSupportPlugin {
|
||||||
@Suppress("DEPRECATION") // implementing to fix KT-39809
|
|
||||||
KotlinGradleSubplugin<AbstractCompile> {
|
|
||||||
|
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
target.extensions.create("kapt", KaptExtension::class.java)
|
target.extensions.create("kapt", KaptExtension::class.java)
|
||||||
@@ -591,20 +589,6 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
|||||||
|
|
||||||
override fun getPluginArtifact(): SubpluginArtifact =
|
override fun getPluginArtifact(): SubpluginArtifact =
|
||||||
JetBrainsSubpluginArtifact(artifactId = KAPT_ARTIFACT_NAME)
|
JetBrainsSubpluginArtifact(artifactId = KAPT_ARTIFACT_NAME)
|
||||||
|
|
||||||
//region Stub implementation for legacy API, KT-39809
|
|
||||||
internal constructor(): this(object : ToolingModelBuilderRegistry {
|
|
||||||
override fun register(p0: ToolingModelBuilder) = Unit
|
|
||||||
override fun getBuilder(p0: String): ToolingModelBuilder? = null
|
|
||||||
})
|
|
||||||
|
|
||||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean = false
|
|
||||||
|
|
||||||
override fun apply(
|
|
||||||
project: Project, kotlinCompile: AbstractCompile, javaCompile: AbstractCompile?, variantData: Any?, androidProjectHandler: Any?,
|
|
||||||
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
|
||||||
): List<SubpluginOption> = emptyList()
|
|
||||||
//endregion
|
|
||||||
}
|
}
|
||||||
private val artifactType = Attribute.of("artifactType", String::class.java)
|
private val artifactType = Attribute.of("artifactType", String::class.java)
|
||||||
|
|
||||||
@@ -708,4 +692,20 @@ private val BaseVariant.dataBindingDependencyArtifactsIfSupported: FileCollectio
|
|||||||
get() = this::class.java.methods
|
get() = this::class.java.methods
|
||||||
.find { it.name == "getDataBindingDependencyArtifacts" }
|
.find { it.name == "getDataBindingDependencyArtifacts" }
|
||||||
?.also { it.isAccessible = true }
|
?.also { it.isAccessible = true }
|
||||||
?.invoke(this) as? FileCollection
|
?.invoke(this) as? FileCollection
|
||||||
|
|
||||||
|
//region Stub implementation for legacy API, KT-39809
|
||||||
|
@Suppress("DEPRECATION") // implementing to fix KT-39809
|
||||||
|
class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<AbstractCompile> {
|
||||||
|
override fun isApplicable(project: Project, task: AbstractCompile): Boolean = false
|
||||||
|
|
||||||
|
override fun apply(
|
||||||
|
project: Project, kotlinCompile: AbstractCompile, javaCompile: AbstractCompile?, variantData: Any?, androidProjectHandler: Any?,
|
||||||
|
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
||||||
|
): List<SubpluginOption> = emptyList()
|
||||||
|
|
||||||
|
override fun getCompilerPluginId(): String = Kapt3GradleSubplugin.KAPT_SUBPLUGIN_ID
|
||||||
|
|
||||||
|
override fun getPluginArtifact(): SubpluginArtifact = JetBrainsSubpluginArtifact(artifactId = Kapt3GradleSubplugin.KAPT_ARTIFACT_NAME)
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user