[Gradle][Minor] Move Kotlin2JsPlugin into separate source file
KT-54312
This commit is contained in:
committed by
Space Team
parent
9cf00c6b9c
commit
7725c8e200
+58
@@ -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<CompilerJsOptions> {
|
||||||
|
override val options: CompilerJsOptions =
|
||||||
|
project.objects.newInstance(CompilerJsOptionsDefault::class.java)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ compilerOptions: CompilerJsOptions ->
|
||||||
|
object : KotlinJsOptions {
|
||||||
|
override val options: CompilerJsOptions
|
||||||
|
get() = compilerOptions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) as KotlinWithJavaTarget<KotlinJsOptions, CompilerJsOptions>
|
||||||
|
|
||||||
|
(project.kotlinExtension as Kotlin2JsProjectExtension).setTarget(target)
|
||||||
|
super.apply(project)
|
||||||
|
}
|
||||||
|
}
|
||||||
-44
@@ -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<KotlinJsCompilerOptions> {
|
|
||||||
override val options: KotlinJsCompilerOptions =
|
|
||||||
project.objects.newInstance(KotlinJsCompilerOptionsDefault::class.java)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ compilerOptions: KotlinJsCompilerOptions ->
|
|
||||||
object : KotlinJsOptions {
|
|
||||||
override val options: KotlinJsCompilerOptions
|
|
||||||
get() = compilerOptions
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) as KotlinWithJavaTarget<KotlinJsOptions, KotlinJsCompilerOptions>
|
|
||||||
|
|
||||||
(project.kotlinExtension as Kotlin2JsProjectExtension).setTarget(target)
|
|
||||||
super.apply(project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal open class KotlinAndroidPlugin(
|
internal open class KotlinAndroidPlugin(
|
||||||
private val registry: ToolingModelBuilderRegistry
|
private val registry: ToolingModelBuilderRegistry
|
||||||
) : Plugin<Project> {
|
) : Plugin<Project> {
|
||||||
|
|||||||
Reference in New Issue
Block a user