From 7725c8e2001430ad4eedf02f4ef684c36012df80 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Tue, 27 Sep 2022 14:21:07 +0200 Subject: [PATCH] [Gradle][Minor] Move Kotlin2JsPlugin into separate source file KT-54312 --- .../kotlin/gradle/plugin/Kotlin2JsPlugin.kt | 58 +++++++++++++++++++ .../kotlin/gradle/plugin/KotlinPlugin.kt | 44 -------------- 2 files changed, 58 insertions(+), 44 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/Kotlin2JsPlugin.kt diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/Kotlin2JsPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/Kotlin2JsPlugin.kt new file mode 100644 index 00000000000..79990bd530b --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/Kotlin2JsPlugin.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2022 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. + */ + +package org.jetbrains.kotlin.gradle.plugin + +import org.gradle.api.Project +import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry +import org.jetbrains.kotlin.gradle.dsl.* +import org.jetbrains.kotlin.gradle.dsl.CompilerJsOptionsDefault +import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinCompilation +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider + +@Deprecated( + message = "Should be removed with Js platform plugin", + level = DeprecationLevel.ERROR +) +internal open class Kotlin2JsPlugin( + registry: ToolingModelBuilderRegistry +) : AbstractKotlinPlugin(KotlinTasksProvider(), registry) { + + companion object { + private const val targetName = "2Js" + } + + override fun buildSourceSetProcessor( + project: Project, + compilation: AbstractKotlinCompilation<*> + ): KotlinSourceSetProcessor<*> = + Kotlin2JsSourceSetProcessor(tasksProvider, compilation) + + override fun apply(project: Project) { + @Suppress("UNCHECKED_CAST") + val target = project.objects.newInstance( + KotlinWithJavaTarget::class.java, + project, + KotlinPlatformType.js, + targetName, + { + object : HasCompilerOptions { + override val options: CompilerJsOptions = + project.objects.newInstance(CompilerJsOptionsDefault::class.java) + } + }, + { compilerOptions: CompilerJsOptions -> + object : KotlinJsOptions { + override val options: CompilerJsOptions + get() = compilerOptions + } + } + ) as KotlinWithJavaTarget + + (project.kotlinExtension as Kotlin2JsProjectExtension).setTarget(target) + super.apply(project) + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt index b0428489623..fa21aa5c8e3 100755 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt @@ -80,50 +80,6 @@ internal open class KotlinPlugin( } } -@Deprecated( - message = "Should be removed with Js platform plugin", - level = DeprecationLevel.ERROR -) -internal open class Kotlin2JsPlugin( - registry: ToolingModelBuilderRegistry -) : AbstractKotlinPlugin(KotlinTasksProvider(), registry) { - - companion object { - private const val targetName = "2Js" - } - - override fun buildSourceSetProcessor( - project: Project, - compilation: AbstractKotlinCompilation<*> - ): KotlinSourceSetProcessor<*> = - Kotlin2JsSourceSetProcessor(tasksProvider, compilation) - - override fun apply(project: Project) { - @Suppress("UNCHECKED_CAST") - val target = project.objects.newInstance( - KotlinWithJavaTarget::class.java, - project, - KotlinPlatformType.js, - targetName, - { - object : HasCompilerOptions { - override val options: KotlinJsCompilerOptions = - project.objects.newInstance(KotlinJsCompilerOptionsDefault::class.java) - } - }, - { compilerOptions: KotlinJsCompilerOptions -> - object : KotlinJsOptions { - override val options: KotlinJsCompilerOptions - get() = compilerOptions - } - } - ) as KotlinWithJavaTarget - - (project.kotlinExtension as Kotlin2JsProjectExtension).setTarget(target) - super.apply(project) - } -} - internal open class KotlinAndroidPlugin( private val registry: ToolingModelBuilderRegistry ) : Plugin {