[Gradle] Restore Kapt import compatibility with older Kotlin plugin releases
Still supported IDEA/Kotlin plugin releases relies on 'kotlin-annotation-processing-gradle' artifact name in compiler plugins classpath. I've restored this publication usage until we will stop support Kotlin plugin versions that doesn't know about 'kotlin-annotation-processing-embeddable' name. ^KTIJ-25586 Fixed
This commit is contained in:
committed by
Space Team
parent
97adb01600
commit
4a501a257e
@@ -3,6 +3,7 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import org.gradle.api.NamedDomainObjectProvider
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
@@ -18,7 +19,8 @@ import java.util.*
|
||||
fun Project.configureSbom(
|
||||
target: String? = null,
|
||||
documentName: String? = null,
|
||||
gradleConfigurations: Iterable<String> = setOf("runtimeClasspath")
|
||||
gradleConfigurations: Iterable<String> = setOf("runtimeClasspath"),
|
||||
publication: NamedDomainObjectProvider<MavenPublication>? = null
|
||||
): TaskProvider<SpdxSbomTask> {
|
||||
val project = this
|
||||
val targetName = target ?: "${mainPublicationName}Publication"
|
||||
@@ -63,6 +65,12 @@ fun Project.configureSbom(
|
||||
val mainPublication = the<PublishingExtension>().publications[mainPublicationName] as MavenPublication
|
||||
mainPublication.artifact(sbomArtifact)
|
||||
}
|
||||
} else if (publication != null) {
|
||||
pluginManager.withPlugin("kotlin-build-publishing") {
|
||||
publication.configure {
|
||||
artifact(sbomArtifact)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return spdxSbomTask
|
||||
|
||||
@@ -104,7 +104,6 @@ dependencies {
|
||||
commonImplementation(project(":compiler:build-tools:kotlin-build-tools-api"))
|
||||
|
||||
commonRuntimeOnly(project(":kotlin-compiler-embeddable"))
|
||||
commonRuntimeOnly(project(":kotlin-annotation-processing-embeddable"))
|
||||
commonRuntimeOnly(project(":kotlin-android-extensions"))
|
||||
commonRuntimeOnly(project(":kotlin-compiler-runner")) {
|
||||
// Excluding dependency with not-relocated 'com.intellij' types
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
|
||||
|
||||
val MAIN_KAPT_CONFIGURATION_NAME = "kapt"
|
||||
|
||||
const val KAPT_ARTIFACT_NAME = "kotlin-annotation-processing-embeddable"
|
||||
const val KAPT_ARTIFACT_NAME = "kotlin-annotation-processing-gradle"
|
||||
val KAPT_SUBPLUGIN_ID = "org.jetbrains.kotlin.kapt3"
|
||||
|
||||
fun getKaptConfigurationName(sourceSetName: String): String {
|
||||
|
||||
+1
-1
@@ -199,7 +199,7 @@ internal class KaptWithoutKotlincConfig : KaptConfig<KaptWithoutKotlincTask> {
|
||||
project.configurations.findByName(Kapt3GradleSubplugin.KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME)
|
||||
?: project.configurations.create(Kapt3GradleSubplugin.KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME).apply {
|
||||
dependencies.addAllLater(project.listProperty {
|
||||
val kaptDependency = "org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:${project.getKotlinPluginVersion()}"
|
||||
val kaptDependency = "org.jetbrains.kotlin:kotlin-annotation-processing-gradle:${project.getKotlinPluginVersion()}"
|
||||
listOf(
|
||||
project.dependencies.create(kaptDependency),
|
||||
project.dependencies.kotlinDependency(
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import org.gradle.api.publish.internal.PublicationInternal
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
|
||||
import plugins.KotlinBuildPublishingPlugin.Companion.ADHOC_COMPONENT_NAME
|
||||
|
||||
description = "Annotation Processor for Kotlin (for using with embeddable compiler)"
|
||||
|
||||
plugins {
|
||||
@@ -10,6 +14,23 @@ dependencies {
|
||||
|
||||
publish()
|
||||
|
||||
// Special compat publication for Kapt/Gradle until we will have minimal
|
||||
// supported IDEA/Kotlin plugin version 1.9.0
|
||||
val publications: PublicationContainer = extensions.getByType<PublishingExtension>().publications
|
||||
val gradleCompatPublication = publications.register<MavenPublication>("gradleCompat") {
|
||||
artifactId = "kotlin-annotation-processing-gradle"
|
||||
from(components[ADHOC_COMPONENT_NAME])
|
||||
|
||||
// Workaround for https://github.com/gradle/gradle/issues/12324
|
||||
(this as PublicationInternal<*>).isAlias = true
|
||||
}
|
||||
val targetName = "${gradleCompatPublication.name.capitalizeAsciiOnly()}Publication"
|
||||
configureSbom(
|
||||
target = targetName,
|
||||
documentName = "kotlin-annotation-processing-gradle",
|
||||
publication = gradleCompatPublication
|
||||
)
|
||||
|
||||
runtimeJar(rewriteDefaultJarDepsToShadedCompiler())
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
Reference in New Issue
Block a user