diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsCompilation.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsCompilation.kt index cc7e3940b3a67..891aab3c149e1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsCompilation.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsCompilation.kt @@ -12,17 +12,17 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinTarget import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJson import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile -open class KotlinJsCompilation( - target: KotlinTarget, - name: String -) : AbstractKotlinCompilationToRunnableFiles(target, name), KotlinCompilationWithResources { - override val processResourcesTaskName: String - get() = disambiguateName("processResources") + open class KotlinJsCompilation( + target: KotlinTarget, + name: String + ) : AbstractKotlinCompilationToRunnableFiles(target, name), KotlinCompilationWithResources { + override val processResourcesTaskName: String + get() = disambiguateName("processResources") - override val compileKotlinTask: Kotlin2JsCompile - get() = super.compileKotlinTask as Kotlin2JsCompile + override val compileKotlinTask: Kotlin2JsCompile + get() = super.compileKotlinTask as Kotlin2JsCompile - internal val packageJsonHandlers = mutableListOf Unit>() + internal val packageJsonHandlers = mutableListOf Unit>() @Suppress("unused") fun packageJson(handler: PackageJson.() -> Unit) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetConfigurator.kt index e9f587dec0e15..090ffa18ba15f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetConfigurator.kt @@ -5,18 +5,17 @@ package org.jetbrains.kotlin.gradle.targets.js -import org.gradle.api.tasks.TaskProvider import org.jetbrains.kotlin.gradle.plugin.Kotlin2JsSourceSetProcessor -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor import org.jetbrains.kotlin.gradle.plugin.KotlinOnlyTargetConfigurator +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTestsConfigurator import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation +import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetConfigurator import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider -import org.jetbrains.kotlin.gradle.testing.internal.KotlinTestReport import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry import org.jetbrains.kotlin.gradle.testing.testTaskName -open class KotlinJsTargetConfigurator(kotlinPluginVersion: String) : +open class KotlinJsTargetConfigurator(kotlinPluginVersion: String, val irConfigurator: KotlinJsIrTargetConfigurator?) : KotlinOnlyTargetConfigurator(true, true, kotlinPluginVersion), KotlinTargetWithTestsConfigurator { @@ -60,5 +59,7 @@ open class KotlinJsTargetConfigurator(kotlinPluginVersion: String) : sourceMapEmbedSources = null } } + + irConfigurator?.configureCompilations(target.irTarget!!) } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetPreset.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetPreset.kt index d6cf08365b041..d7e4d466ed6e0 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetPreset.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsTargetPreset.kt @@ -14,12 +14,13 @@ import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTargetConfigurator import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget +import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetConfigurator import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset open class KotlinJsTargetPreset( project: Project, kotlinPluginVersion: String, - irPreset: KotlinJsIrTargetPreset? + val irPreset: KotlinJsIrTargetPreset? ) : KotlinOnlyTargetPreset( project, kotlinPluginVersion @@ -47,6 +48,12 @@ open class KotlinJsTargetPreset( val compilationFactory = createCompilationFactory(this) compilations = project.container(compilationFactory.itemClass, compilationFactory) + + if (irTarget != null) { + val irCompilationFactory = irPreset?.createCompilationFactory(irTarget)!! + irTarget.targetName = "${name}Ir" + irTarget.compilations = project.container(irCompilationFactory.itemClass, irCompilationFactory) + } } createKotlinTargetConfigurator().configureTarget(result) @@ -54,13 +61,16 @@ open class KotlinJsTargetPreset( return result } - override fun createKotlinTargetConfigurator() = KotlinJsTargetConfigurator(kotlinPluginVersion) + override fun createKotlinTargetConfigurator() = KotlinJsTargetConfigurator( + kotlinPluginVersion, + irPreset?.let { KotlinJsIrTargetConfigurator(kotlinPluginVersion) } + ) override fun getName(): String = PRESET_NAME override fun createCompilationFactory(forTarget: KotlinOnlyTarget): KotlinJsCompilationFactory { forTarget as KotlinJsTarget - return KotlinJsCompilationFactory(project, forTarget, forTarget.irTarget) + return KotlinJsCompilationFactory(project, forTarget, irPreset?.let { forTarget.irTarget }) } companion object { @@ -81,5 +91,8 @@ class KotlinJsSingleTargetPreset( // In a Kotlin/JS single-platform project, we don't need any disambiguation suffixes or prefixes in the names: override fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget): String? = null - override fun createKotlinTargetConfigurator() = KotlinJsTargetConfigurator(kotlinPluginVersion) + override fun createKotlinTargetConfigurator() = KotlinJsTargetConfigurator( + kotlinPluginVersion, + irPreset?.let { KotlinJsIrTargetConfigurator(kotlinPluginVersion) } + ) } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPreset.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPreset.kt index 3f15e90021587..195886646617c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPreset.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPreset.kt @@ -9,7 +9,6 @@ import org.gradle.api.Project import org.jetbrains.kotlin.gradle.plugin.KotlinOnlyTargetConfigurator import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinCompilationFactory -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilationFactory import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTargetPreset @@ -32,7 +31,8 @@ open class KotlinJsIrTargetPreset( override fun getName(): String = PRESET_NAME - override fun createCompilationFactory( + //TODO[Ilya Goncharov] remove public morozov + public override fun createCompilationFactory( forTarget: KotlinOnlyTarget ): KotlinCompilationFactory = KotlinJsIrCompilationFactory(project, forTarget)