Remove 'KotlinGradleSubplugin'
^KT-48831 Fixed
This commit is contained in:
+7
-13
@@ -20,33 +20,29 @@ import com.intellij.mock.MockProject
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.compiler.plugin.CliOption
|
||||
import org.jetbrains.kotlin.compiler.plugin.CliOptionProcessingException
|
||||
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
|
||||
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
|
||||
import org.jetbrains.kotlin.compiler.plugin.*
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.CompilerConfigurationKey
|
||||
|
||||
public object ExampleConfigurationKeys {
|
||||
public val EXAMPLE_KEY: CompilerConfigurationKey<String> = CompilerConfigurationKey.create<String>("example argument")
|
||||
public val EXAMPLE_LEGACY_KEY: CompilerConfigurationKey<String> = CompilerConfigurationKey.create<String>("example legacy argument")
|
||||
}
|
||||
|
||||
public class ExampleCommandLineProcessor : CommandLineProcessor {
|
||||
companion object {
|
||||
public val EXAMPLE_PLUGIN_ID: String = "example.plugin"
|
||||
public const val EXAMPLE_PLUGIN_ID: String = "example.plugin"
|
||||
public val EXAMPLE_OPTION: CliOption = CliOption("exampleKey", "<value>", "")
|
||||
public val EXAMPLE_LEGACY_OPTION: CliOption = CliOption("exampleLegacyKey", "<value>", "")
|
||||
}
|
||||
|
||||
override val pluginId: String = EXAMPLE_PLUGIN_ID
|
||||
override val pluginOptions: Collection<CliOption> = listOf(EXAMPLE_OPTION, EXAMPLE_LEGACY_OPTION)
|
||||
override val pluginOptions: Collection<CliOption> = listOf(EXAMPLE_OPTION)
|
||||
|
||||
@Deprecated("Implement processOption(option: AbstractCliOption, value: String, configuration: CompilerConfiguration) instead.")
|
||||
override fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration) {
|
||||
override fun processOption(
|
||||
option: AbstractCliOption,
|
||||
value: String, configuration: CompilerConfiguration
|
||||
) {
|
||||
when (option) {
|
||||
EXAMPLE_OPTION -> configuration.put(ExampleConfigurationKeys.EXAMPLE_KEY, value)
|
||||
EXAMPLE_LEGACY_OPTION -> configuration.put(ExampleConfigurationKeys.EXAMPLE_LEGACY_KEY, value)
|
||||
else -> throw CliOptionProcessingException("Unknown option: ${option.optionName}")
|
||||
}
|
||||
}
|
||||
@@ -55,9 +51,7 @@ public class ExampleCommandLineProcessor : CommandLineProcessor {
|
||||
public class ExampleComponentRegistrar : ComponentRegistrar {
|
||||
public override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
||||
val exampleValue = configuration.get(ExampleConfigurationKeys.EXAMPLE_KEY)
|
||||
val exampleLegacyValue = configuration.get(ExampleConfigurationKeys.EXAMPLE_LEGACY_KEY)
|
||||
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
|
||||
messageCollector.report(CompilerMessageSeverity.INFO, "Project component registration: $exampleValue")
|
||||
messageCollector.report(CompilerMessageSeverity.INFO, "Project component registration: $exampleLegacyValue")
|
||||
}
|
||||
}
|
||||
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package example
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
|
||||
class ExampleLegacySubplugin : @Suppress("DEPRECATION_ERROR") KotlinGradleSubplugin<AbstractCompile> {
|
||||
|
||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun apply(
|
||||
project: Project,
|
||||
kotlinCompile: AbstractCompile,
|
||||
javaCompile: AbstractCompile?,
|
||||
variantData: Any?,
|
||||
androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<*>?
|
||||
): List<SubpluginOption> {
|
||||
println("ExampleLegacySubplugin loaded")
|
||||
return listOf(
|
||||
SubpluginOption("exampleLegacyKey", "exampleLegacyValue")
|
||||
)
|
||||
}
|
||||
|
||||
override fun getCompilerPluginId(): String {
|
||||
return "example.plugin"
|
||||
}
|
||||
|
||||
override fun getPluginArtifact(): SubpluginArtifact =
|
||||
JetBrainsSubpluginArtifact("kotlin-gradle-subplugin-example")
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
#
|
||||
# Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
#
|
||||
|
||||
example.ExampleLegacySubplugin
|
||||
+2
-21
@@ -16,15 +16,11 @@
|
||||
|
||||
package org.jetbrains.kotlinx.atomicfu.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
|
||||
class AtomicfuKotlinGradleSubplugin :
|
||||
KotlinCompilerPluginSupportPlugin,
|
||||
@Suppress("DEPRECATION_ERROR") // implementing to fix KT-39809
|
||||
KotlinGradleSubplugin<AbstractCompile> {
|
||||
KotlinCompilerPluginSupportPlugin {
|
||||
companion object {
|
||||
const val ATOMICFU_ARTIFACT_NAME = "atomicfu"
|
||||
}
|
||||
@@ -34,25 +30,10 @@ class AtomicfuKotlinGradleSubplugin :
|
||||
override fun applyToCompilation(
|
||||
kotlinCompilation: KotlinCompilation<*>
|
||||
): Provider<List<SubpluginOption>> =
|
||||
kotlinCompilation.target.project.provider { emptyList<SubpluginOption>() }
|
||||
kotlinCompilation.target.project.provider { emptyList() }
|
||||
|
||||
override fun getPluginArtifact(): SubpluginArtifact =
|
||||
JetBrainsSubpluginArtifact(ATOMICFU_ARTIFACT_NAME)
|
||||
|
||||
override fun getCompilerPluginId() = "org.jetbrains.kotlinx.atomicfu"
|
||||
|
||||
//region Stub implementation for legacy API, KT-39809
|
||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean = true
|
||||
|
||||
override fun apply(
|
||||
project: Project,
|
||||
kotlinCompile: AbstractCompile,
|
||||
javaCompile: AbstractCompile?,
|
||||
variantData: Any?,
|
||||
androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<*>?
|
||||
): List<SubpluginOption> {
|
||||
return emptyList()
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
+4
-25
@@ -16,21 +16,17 @@
|
||||
|
||||
package org.jetbrains.kotlin.allopen.gradle
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilder
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.allopen.gradle.model.builder.AllOpenModelBuilder
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AllOpenGradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
|
||||
KotlinCompilerPluginSupportPlugin,
|
||||
@Suppress("DEPRECATION_ERROR") // implementing to fix KT-39809
|
||||
KotlinGradleSubplugin<AbstractCompile> {
|
||||
class AllOpenGradleSubplugin
|
||||
@Inject internal constructor(
|
||||
private val registry: ToolingModelBuilderRegistry
|
||||
) : KotlinCompilerPluginSupportPlugin {
|
||||
|
||||
companion object {
|
||||
fun getAllOpenExtension(project: Project): AllOpenExtension {
|
||||
@@ -75,21 +71,4 @@ class AllOpenGradleSubplugin @Inject internal constructor(private val registry:
|
||||
override fun getCompilerPluginId() = "org.jetbrains.kotlin.allopen"
|
||||
override fun getPluginArtifact(): SubpluginArtifact =
|
||||
JetBrainsSubpluginArtifact(artifactId = ALLOPEN_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 = error("Method should not be called")
|
||||
})
|
||||
|
||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean = true
|
||||
|
||||
override fun apply(
|
||||
project: Project, kotlinCompile: AbstractCompile, javaCompile: AbstractCompile?, variantData: Any?, androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
||||
): List<SubpluginOption> = throw GradleException(
|
||||
"This version of the kotlin-allopen Gradle plugin is built for a newer Kotlin version. " +
|
||||
"Please use an older version of kotlin-allopen or upgrade the Kotlin Gradle plugin version to make them match."
|
||||
)
|
||||
//endregion
|
||||
}
|
||||
|
||||
-33
@@ -19,8 +19,6 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import java.io.File
|
||||
|
||||
open class SubpluginOption(val key: String, private val lazyValue: Lazy<String>) {
|
||||
@@ -75,37 +73,6 @@ open class CompilerPluginConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// Deprecated because most calls require the tasks to be instantiated, which is not compatible with Gradle task configuration avoidance.
|
||||
@Deprecated(
|
||||
message = "This interface will be removed due to performance considerations. " +
|
||||
"Please use the KotlinCompilerPluginSupportPlugin interface instead " +
|
||||
"and remove the META-INF/services/org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin entry.",
|
||||
replaceWith = ReplaceWith("KotlinCompilerPluginSupportPlugin"),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
interface KotlinGradleSubplugin<in KotlinCompile : AbstractCompile> {
|
||||
fun isApplicable(project: Project, task: AbstractCompile): Boolean
|
||||
|
||||
fun apply(
|
||||
project: Project,
|
||||
kotlinCompile: KotlinCompile,
|
||||
javaCompile: AbstractCompile?,
|
||||
variantData: Any?,
|
||||
androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
||||
): List<SubpluginOption>
|
||||
|
||||
fun getSubpluginKotlinTasks(
|
||||
project: Project,
|
||||
kotlinCompile: KotlinCompile
|
||||
): List<AbstractCompile> = emptyList()
|
||||
|
||||
fun getCompilerPluginId(): String
|
||||
|
||||
fun getPluginArtifact(): SubpluginArtifact
|
||||
fun getNativeCompilerPluginArtifact(): SubpluginArtifact? = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Gradle plugin implementing support for a Kotlin compiler plugin.
|
||||
*
|
||||
|
||||
-45
@@ -24,17 +24,13 @@ class SubpuginsIT : KGPBaseTest() {
|
||||
build("compileKotlin", "build") {
|
||||
assertTasksExecuted(":compileKotlin")
|
||||
assertOutputContains("ExampleSubplugin loaded")
|
||||
assertOutputContains("ExampleLegacySubplugin loaded")
|
||||
assertOutputContains("Project component registration: exampleValue")
|
||||
assertOutputContains("Project component registration: exampleLegacyValue")
|
||||
}
|
||||
|
||||
build("compileKotlin", "build") {
|
||||
assertTasksUpToDate(":compileKotlin")
|
||||
assertOutputContains("ExampleSubplugin loaded")
|
||||
assertOutputContains("ExampleLegacySubplugin loaded")
|
||||
assertOutputDoesNotContain("Project component registration: exampleValue")
|
||||
assertOutputDoesNotContain("Project component registration: exampleLegacyValue")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,47 +175,6 @@ class SubpuginsIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-39809: subplugins legacy loading does not fail the build")
|
||||
@GradleTest
|
||||
fun testKotlinVersionDowngradeWithNewerSubpluginsKt39809(gradleVersion: GradleVersion) {
|
||||
project("multiprojectWithDependency", gradleVersion) {
|
||||
|
||||
val projectA = subProject("projA")
|
||||
val subprojectBuildGradle = projectA.buildGradle
|
||||
val originalScript = subprojectBuildGradle.readText()
|
||||
|
||||
listOf("allopen", "noarg", "sam-with-receiver", "serialization").forEach { plugin ->
|
||||
subprojectBuildGradle.modify {
|
||||
"""
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-$plugin:${defaultBuildOptions.kotlinVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "org.jetbrains.kotlin.plugin.${plugin.replace("-", ".")}"
|
||||
|
||||
$originalScript
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
buildAndFail(
|
||||
":projA:compileKotlin",
|
||||
buildOptions = defaultBuildOptions.copy(kotlinVersion = "1.3.72")
|
||||
) {
|
||||
assertOutputContains(
|
||||
"This version of the kotlin-$plugin Gradle plugin is built for a newer Kotlin version. " +
|
||||
"Please use an older version of kotlin-$plugin or upgrade the Kotlin Gradle plugin version to make them match."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Lombok plugin is working")
|
||||
@GradleTest
|
||||
fun testLombokPlugin(gradleVersion: GradleVersion) {
|
||||
|
||||
-17
@@ -25,7 +25,6 @@ import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.gradle.process.CommandLineArgumentProvider
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.internal.kapt.incremental.CLASS_STRUCTURE_ARTIFACT_TYPE
|
||||
import org.jetbrains.kotlin.gradle.internal.kapt.incremental.StructureTransformAction
|
||||
@@ -852,19 +851,3 @@ private val BaseVariant.dataBindingDependencyArtifactsIfSupported: FileCollectio
|
||||
.find { it.name == "getDataBindingDependencyArtifacts" }
|
||||
?.also { it.isAccessible = true }
|
||||
?.invoke(this) as? FileCollection
|
||||
|
||||
//region Stub implementation for legacy API, KT-39809
|
||||
@Suppress("DEPRECATION_ERROR") // 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
|
||||
|
||||
+1
-77
@@ -1,7 +1,6 @@
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
@@ -16,8 +15,6 @@ import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation
|
||||
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.thisTaskProvider
|
||||
import java.util.*
|
||||
|
||||
class SubpluginEnvironment(
|
||||
private val subplugins: List<KotlinCompilerPluginSupportPlugin>,
|
||||
@@ -26,36 +23,7 @@ class SubpluginEnvironment(
|
||||
companion object {
|
||||
fun loadSubplugins(project: Project): SubpluginEnvironment {
|
||||
val kotlinPluginVersion = project.getKotlinPluginVersion()
|
||||
return try {
|
||||
@Suppress("DEPRECATION_ERROR") // support for the deprecated plugin API
|
||||
val klass = KotlinGradleSubplugin::class.java
|
||||
val buildscriptClassloader = project.buildscript.classLoader
|
||||
val klassFromBuildscript = try {
|
||||
buildscriptClassloader.loadClass(klass.canonicalName)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
null
|
||||
}
|
||||
|
||||
val classloader = if (klass == klassFromBuildscript) {
|
||||
buildscriptClassloader
|
||||
} else {
|
||||
klass.classLoader
|
||||
}
|
||||
|
||||
val result = project.plugins.filterIsInstance<KotlinCompilerPluginSupportPlugin>()
|
||||
|
||||
@Suppress("DEPRECATION_ERROR", "UNCHECKED_CAST")
|
||||
val compatibilitySubplugins = ServiceLoader.load(klass, classloader)
|
||||
.filter { it !is KotlinCompilerPluginSupportPlugin }
|
||||
.map { LegacyKotlinCompilerPluginSupportPlugin(it as KotlinGradleSubplugin<AbstractCompile>) }
|
||||
|
||||
SubpluginEnvironment(result + compatibilitySubplugins, kotlinPluginVersion)
|
||||
} catch (e: NoClassDefFoundError) {
|
||||
// Skip plugin loading if KotlinGradleSubplugin is not defined.
|
||||
// It is true now for tests in kotlin-gradle-plugin-core.
|
||||
project.logger.error("Could not load subplugins", e)
|
||||
SubpluginEnvironment(listOf(), kotlinPluginVersion)
|
||||
}
|
||||
return SubpluginEnvironment(project.plugins.filterIsInstance<KotlinCompilerPluginSupportPlugin>(), kotlinPluginVersion)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,12 +70,6 @@ class SubpluginEnvironment(
|
||||
}
|
||||
|
||||
project.logger.kotlinDebug("Subplugin $pluginId loaded")
|
||||
|
||||
if (subplugin is LegacyKotlinCompilerPluginSupportPlugin) {
|
||||
subplugin.getPluginKotlinTasks(kotlinCompilation).forEach { task ->
|
||||
addCompilationSourcesToExternalCompileTask(kotlinCompilation, task.thisTaskProvider)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return appliedSubplugins
|
||||
@@ -138,44 +100,6 @@ internal fun addCompilationSourcesToExternalCompileTask(compilation: KotlinCompi
|
||||
}
|
||||
}
|
||||
|
||||
internal class LegacyKotlinCompilerPluginSupportPlugin(
|
||||
@Suppress("DEPRECATION_ERROR") // support for deprecated API
|
||||
val oldPlugin: KotlinGradleSubplugin<AbstractCompile>
|
||||
) : KotlinCompilerPluginSupportPlugin {
|
||||
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
|
||||
oldPlugin.isApplicable(kotlinCompilation.target.project, kotlinCompilation.compileKotlinTaskProvider.get() as AbstractCompile)
|
||||
|
||||
override fun applyToCompilation(
|
||||
kotlinCompilation: KotlinCompilation<*>
|
||||
): Provider<List<SubpluginOption>> {
|
||||
val project = kotlinCompilation.target.project
|
||||
|
||||
val androidProjectHandlerOrNull: AbstractAndroidProjectHandler? =
|
||||
if (kotlinCompilation is KotlinJvmAndroidCompilation) KotlinAndroidPlugin.androidTargetHandler() else null
|
||||
|
||||
val variantData = (kotlinCompilation as? KotlinJvmAndroidCompilation)?.androidVariant
|
||||
|
||||
val result = oldPlugin.apply(
|
||||
project,
|
||||
kotlinCompilation.compileKotlinTask as AbstractCompile,
|
||||
findJavaTaskForKotlinCompilation(kotlinCompilation)?.get(),
|
||||
variantData,
|
||||
androidProjectHandlerOrNull,
|
||||
if (variantData != null) null else kotlinCompilation
|
||||
)
|
||||
|
||||
return project.provider { result }
|
||||
}
|
||||
|
||||
fun getPluginKotlinTasks(compilation: KotlinCompilation<*>): List<AbstractCompile> {
|
||||
val project = compilation.target.project
|
||||
return oldPlugin.getSubpluginKotlinTasks(project, compilation.compileKotlinTask as AbstractCompile)
|
||||
}
|
||||
|
||||
override fun getCompilerPluginId(): String = oldPlugin.getCompilerPluginId()
|
||||
override fun getPluginArtifact(): SubpluginArtifact = oldPlugin.getPluginArtifact()
|
||||
override fun getPluginArtifactForNative(): SubpluginArtifact? = oldPlugin.getNativeCompilerPluginArtifact()
|
||||
}
|
||||
|
||||
internal fun findJavaTaskForKotlinCompilation(compilation: KotlinCompilation<*>): TaskProvider<out JavaCompile>? =
|
||||
when (compilation) {
|
||||
|
||||
+1
-16
@@ -18,10 +18,8 @@ import org.gradle.api.attributes.Attribute
|
||||
import org.gradle.api.file.FileSystemLocation
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||
import org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
@@ -30,7 +28,6 @@ import org.jetbrains.kotlin.gradle.scripting.ScriptingExtension
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.scripting.compiler.plugin.impl.reporter
|
||||
import org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionsFromClasspathDiscoverySource
|
||||
import java.io.File
|
||||
import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
|
||||
|
||||
private const val SCRIPTING_LOG_PREFIX = "kotlin scripting plugin:"
|
||||
@@ -211,10 +208,7 @@ private fun Configuration.discoverScriptExtensionsFiles() =
|
||||
}.artifacts.artifactFiles
|
||||
|
||||
|
||||
class ScriptingKotlinGradleSubplugin :
|
||||
KotlinCompilerPluginSupportPlugin,
|
||||
@Suppress("DEPRECATION_ERROR") // implementing to fix KT-39809
|
||||
KotlinGradleSubplugin<KotlinCompile> {
|
||||
class ScriptingKotlinGradleSubplugin : KotlinCompilerPluginSupportPlugin {
|
||||
companion object {
|
||||
const val SCRIPTING_ARTIFACT_NAME = "kotlin-scripting-compiler-embeddable"
|
||||
|
||||
@@ -257,13 +251,4 @@ class ScriptingKotlinGradleSubplugin :
|
||||
override fun getCompilerPluginId() = "kotlin.scripting"
|
||||
override fun getPluginArtifact(): SubpluginArtifact =
|
||||
JetBrainsSubpluginArtifact(artifactId = SCRIPTING_ARTIFACT_NAME)
|
||||
|
||||
//region Stub implementation for legacy API, KT-39809
|
||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean = false
|
||||
|
||||
override fun apply(
|
||||
project: Project, kotlinCompile: KotlinCompile, javaCompile: AbstractCompile?, variantData: Any?, androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
||||
): List<SubpluginOption> = emptyList()
|
||||
//endregion
|
||||
}
|
||||
|
||||
+1
-16
@@ -17,10 +17,8 @@ import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.PathSensitivity
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.model.builder.KotlinAndroidExtensionModelBuilder
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
|
||||
@@ -72,11 +70,7 @@ class AndroidExtensionsSubpluginIndicator @Inject internal constructor(private v
|
||||
}
|
||||
}
|
||||
|
||||
class AndroidSubplugin :
|
||||
KotlinCompilerPluginSupportPlugin,
|
||||
@Suppress("DEPRECATION_ERROR") // implementing to fix KT-39809
|
||||
KotlinGradleSubplugin<AbstractCompile>
|
||||
{
|
||||
class AndroidSubplugin : KotlinCompilerPluginSupportPlugin {
|
||||
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean {
|
||||
if (kotlinCompilation !is KotlinJvmAndroidCompilation)
|
||||
return false
|
||||
@@ -332,13 +326,4 @@ class AndroidSubplugin :
|
||||
val builder = factory.newDocumentBuilder()
|
||||
return builder.parse(this)
|
||||
}
|
||||
|
||||
//region Stub implementation for legacy API, KT-39809
|
||||
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
|
||||
}
|
||||
|
||||
+4
-25
@@ -16,21 +16,17 @@
|
||||
|
||||
package org.jetbrains.kotlin.noarg.gradle
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilder
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.noarg.gradle.model.builder.NoArgModelBuilder
|
||||
import javax.inject.Inject
|
||||
|
||||
class NoArgGradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
|
||||
KotlinCompilerPluginSupportPlugin,
|
||||
@Suppress("DEPRECATION_ERROR") // implementing to fix KT-39809
|
||||
KotlinGradleSubplugin<AbstractCompile> {
|
||||
class NoArgGradleSubplugin
|
||||
@Inject internal constructor(
|
||||
private val registry: ToolingModelBuilderRegistry
|
||||
) : KotlinCompilerPluginSupportPlugin {
|
||||
|
||||
companion object {
|
||||
fun getNoArgExtension(project: Project): NoArgExtension {
|
||||
@@ -79,21 +75,4 @@ class NoArgGradleSubplugin @Inject internal constructor(private val registry: To
|
||||
override fun getCompilerPluginId() = "org.jetbrains.kotlin.noarg"
|
||||
override fun getPluginArtifact(): SubpluginArtifact =
|
||||
JetBrainsSubpluginArtifact(artifactId = NOARG_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 = error("Method should not be called")
|
||||
})
|
||||
|
||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean = true
|
||||
|
||||
override fun apply(
|
||||
project: Project, kotlinCompile: AbstractCompile, javaCompile: AbstractCompile?, variantData: Any?, androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
||||
): List<SubpluginOption> = throw GradleException(
|
||||
"This version of the kotlin-noarg Gradle plugin is built for a newer Kotlin version. " +
|
||||
"Please use an older version of kotlin-noarg or upgrade the Kotlin Gradle plugin version to make them match."
|
||||
)
|
||||
//endregion
|
||||
}
|
||||
|
||||
+5
-26
@@ -16,21 +16,17 @@
|
||||
|
||||
package org.jetbrains.kotlin.samWithReceiver.gradle
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilder
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.noarg.gradle.model.builder.SamWithReceiverModelBuilder
|
||||
import javax.inject.Inject
|
||||
|
||||
class SamWithReceiverGradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
|
||||
KotlinCompilerPluginSupportPlugin,
|
||||
@Suppress("DEPRECATION_ERROR") // implementing to fix KT-39809
|
||||
KotlinGradleSubplugin<AbstractCompile> {
|
||||
class SamWithReceiverGradleSubplugin
|
||||
@Inject internal constructor(
|
||||
private val registry: ToolingModelBuilderRegistry
|
||||
) : KotlinCompilerPluginSupportPlugin {
|
||||
|
||||
override fun apply(target: Project) {
|
||||
target.extensions.create("samWithReceiver", SamWithReceiverExtension::class.java)
|
||||
@@ -54,7 +50,7 @@ class SamWithReceiverGradleSubplugin @Inject internal constructor(private val re
|
||||
val samWithReceiverExtension =
|
||||
project.extensions.findByType(SamWithReceiverExtension::class.java) ?: return project.provider { emptyList<SubpluginOption>() }
|
||||
|
||||
return project.provider<List<SubpluginOption>> {
|
||||
return project.provider {
|
||||
val options = mutableListOf<SubpluginOption>()
|
||||
|
||||
for (anno in samWithReceiverExtension.myAnnotations) {
|
||||
@@ -72,21 +68,4 @@ class SamWithReceiverGradleSubplugin @Inject internal constructor(private val re
|
||||
override fun getCompilerPluginId() = "org.jetbrains.kotlin.samWithReceiver"
|
||||
override fun getPluginArtifact(): SubpluginArtifact =
|
||||
JetBrainsSubpluginArtifact(artifactId = SAM_WITH_RECEIVER_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 = error("Method should not be called")
|
||||
})
|
||||
|
||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean = true
|
||||
|
||||
override fun apply(
|
||||
project: Project, kotlinCompile: AbstractCompile, javaCompile: AbstractCompile?, variantData: Any?, androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
||||
): List<SubpluginOption> = throw GradleException(
|
||||
"This version of the kotlin-sam-with-receiver Gradle plugin is built for a newer Kotlin version. " +
|
||||
"Please use an older version of kotlin-sam-with-receiver or upgrade the Kotlin Gradle plugin version to make them match."
|
||||
)
|
||||
//endregion
|
||||
}
|
||||
|
||||
+3
-24
@@ -16,20 +16,11 @@
|
||||
|
||||
package org.jetbrains.kotlinx.serialization.gradle
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilder
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
class SerializationGradleSubplugin :
|
||||
KotlinCompilerPluginSupportPlugin,
|
||||
@Suppress("DEPRECATION_ERROR") // implementing to fix KT-39809
|
||||
KotlinGradleSubplugin<AbstractCompile> {
|
||||
KotlinCompilerPluginSupportPlugin {
|
||||
|
||||
companion object {
|
||||
const val SERIALIZATION_GROUP_NAME = "org.jetbrains.kotlin"
|
||||
@@ -42,25 +33,13 @@ class SerializationGradleSubplugin :
|
||||
override fun applyToCompilation(
|
||||
kotlinCompilation: KotlinCompilation<*>
|
||||
): Provider<List<SubpluginOption>> =
|
||||
kotlinCompilation.target.project.provider { emptyList<SubpluginOption>() }
|
||||
kotlinCompilation.target.project.provider { emptyList() }
|
||||
|
||||
override fun getPluginArtifact(): SubpluginArtifact =
|
||||
SubpluginArtifact(SERIALIZATION_GROUP_NAME, SERIALIZATION_ARTIFACT_NAME)
|
||||
|
||||
override fun getPluginArtifactForNative(): SubpluginArtifact? =
|
||||
override fun getPluginArtifactForNative(): SubpluginArtifact =
|
||||
SubpluginArtifact(SERIALIZATION_GROUP_NAME, SERIALIZATION_ARTIFACT_UNSHADED_NAME)
|
||||
|
||||
override fun getCompilerPluginId() = "org.jetbrains.kotlinx.serialization"
|
||||
|
||||
//region Stub implementation for legacy API, KT-39809
|
||||
override fun isApplicable(project: Project, task: AbstractCompile): Boolean = true
|
||||
|
||||
override fun apply(
|
||||
project: Project, kotlinCompile: AbstractCompile, javaCompile: AbstractCompile?, variantData: Any?, androidProjectHandler: Any?,
|
||||
kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
|
||||
): List<SubpluginOption> = throw GradleException(
|
||||
"This version of the kotlin-serialization Gradle plugin is built for a newer Kotlin version. " +
|
||||
"Please use an older version of kotlin-serialization or upgrade the Kotlin Gradle plugin version to make them match."
|
||||
)
|
||||
//endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user