From bb635d1bdb26336c6a40296e89d03432f1598f53 Mon Sep 17 00:00:00 2001 From: "Alexander.Likhachev" Date: Fri, 17 Mar 2023 17:35:00 +0100 Subject: [PATCH] [Gradle] Add `useCompilerVersion` to Kotlin extension It allows to override default Kotlin compiler version that is used to run compilation via the build tools api #KT-57397 In Progress --- .../kotlin/gradle/dsl/KotlinProjectExtension.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt index 1db15cbd59b..6fa69f55862 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt @@ -142,6 +142,17 @@ abstract class KotlinTopLevelExtension(internal val project: Project) : KotlinTo } } } + + /** + * Allows to use a different version of the Kotlin Build Tools API implementation and effectively a different version of the compiler. + * + * By default, the Kotlin Build Tools API implementation of the same version as the KGP is used. + * + * Currently only has an effect if the `kotlin.compiler.runViaBuildToolsApi` Gradle property is set to `true`. + */ + fun useCompilerVersion(version: String) { + project.dependencies.add(BUILD_TOOLS_API_CLASSPATH_CONFIGURATION_NAME, "$KOTLIN_MODULE_GROUP:$KOTLIN_BUILD_TOOLS_API_IMPL:$version") + } } open class KotlinProjectExtension @Inject constructor(project: Project) : KotlinTopLevelExtension(project), KotlinSourceSetContainer {