Revert "[Gradle, JS] binaries API instead of produce*"
This reverts commit 055e98e9
This commit is contained in:
+36
-19
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle.targets.js
|
|||||||
import org.gradle.api.NamedDomainObjectContainer
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.tasks.TaskProvider
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.gradle.util.WrapUtil
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
@@ -17,8 +16,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetComponent
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetComponent
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinBinaryContainer
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.PRIMARY_SINGLE_COMPONENT_NAME
|
import org.jetbrains.kotlin.gradle.plugin.mpp.PRIMARY_SINGLE_COMPONENT_NAME
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBrowserDsl
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBrowserDsl
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsNodeDsl
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsNodeDsl
|
||||||
@@ -27,6 +26,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
|||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.JsBinary
|
import org.jetbrains.kotlin.gradle.targets.js.ir.JsBinary
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.*
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.*
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.*
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsBinaryContainer
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsBinaryContainer
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinBrowserJs
|
import org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinBrowserJs
|
||||||
@@ -45,7 +45,7 @@ constructor(
|
|||||||
project: Project,
|
project: Project,
|
||||||
platformType: KotlinPlatformType
|
platformType: KotlinPlatformType
|
||||||
) :
|
) :
|
||||||
KotlinBinaryContainer<KotlinJsCompilation, KotlinJsBinaryContainer>(project, platformType),
|
KotlinOnlyTarget<KotlinJsCompilation>(project, platformType),
|
||||||
KotlinTargetWithTests<JsAggregatingExecutionSource, KotlinJsReportAggregatingTestRun>,
|
KotlinTargetWithTests<JsAggregatingExecutionSource, KotlinJsReportAggregatingTestRun>,
|
||||||
KotlinJsTargetDsl,
|
KotlinJsTargetDsl,
|
||||||
KotlinJsSubTargetContainerDsl {
|
KotlinJsSubTargetContainerDsl {
|
||||||
@@ -90,23 +90,11 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val binaries: KotlinJsBinaryContainer =
|
var producingType: KotlinJsProducingType? = null
|
||||||
// Use newInstance to allow accessing binaries by their names in Groovy using the extension mechanism.
|
|
||||||
project.objects.newInstance(
|
|
||||||
KotlinJsBinaryContainer::class.java,
|
|
||||||
this,
|
|
||||||
WrapUtil.toDomainObjectSet(JsBinary::class.java).apply {
|
|
||||||
all {
|
|
||||||
whenBrowserConfigured {
|
|
||||||
(this as KotlinJsSubTarget).produceExecutable()
|
|
||||||
}
|
|
||||||
|
|
||||||
whenNodejsConfigured {
|
@Deprecated("Use produceExecutable instead", ReplaceWith("produceExecutable()"))
|
||||||
(this as KotlinJsSubTarget).produceExecutable()
|
override val binaries: KotlinJsBinaryContainer =
|
||||||
}
|
throw IllegalStateException("binaries is useless for legacy compiler. Use produceExecutable instead")
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
var irTarget: KotlinJsIrTarget? = null
|
var irTarget: KotlinJsIrTarget? = null
|
||||||
|
|
||||||
@@ -166,6 +154,35 @@ constructor(
|
|||||||
irTarget?.nodejs(body)
|
irTarget?.nodejs(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun produceExecutable() {
|
||||||
|
produce(KotlinJsProducingType.EXECUTABLE) {
|
||||||
|
(this as KotlinJsSubTarget).produceExecutable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun produce(
|
||||||
|
producingType: KotlinJsProducingType,
|
||||||
|
producer: KotlinJsSubTargetDsl.() -> Unit = {}
|
||||||
|
) {
|
||||||
|
check(this.producingType == null || this.producingType == producingType) {
|
||||||
|
"Only one producing type supported. Try to set $producingType but previously ${this.producingType} found"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.producingType = producingType
|
||||||
|
|
||||||
|
whenBrowserConfigured {
|
||||||
|
if (this is KotlinBrowserJs) {
|
||||||
|
producer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
whenNodejsConfigured {
|
||||||
|
if (this is KotlinNodeJs) {
|
||||||
|
producer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun whenBrowserConfigured(body: KotlinJsBrowserDsl.() -> Unit) {
|
override fun whenBrowserConfigured(body: KotlinJsBrowserDsl.() -> Unit) {
|
||||||
if (browserLazyDelegate.isInitialized()) {
|
if (browserLazyDelegate.isInitialized()) {
|
||||||
browser(body)
|
browser(body)
|
||||||
|
|||||||
+2
@@ -49,6 +49,8 @@ interface KotlinJsTargetDsl : KotlinTarget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun produceExecutable()
|
||||||
|
|
||||||
fun useCommonJs()
|
fun useCommonJs()
|
||||||
|
|
||||||
val binaries: KotlinJsBinaryContainer
|
val binaries: KotlinJsBinaryContainer
|
||||||
|
|||||||
+5
@@ -115,6 +115,11 @@ constructor(
|
|||||||
body(nodejs)
|
body(nodejs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Use binaries.executable instead", ReplaceWith("binaries.executable()"))
|
||||||
|
override fun produceExecutable() {
|
||||||
|
project.logger.warn("produceExecutable configuration is useless with IR compiler")
|
||||||
|
}
|
||||||
|
|
||||||
override fun whenBrowserConfigured(body: KotlinJsBrowserDsl.() -> Unit) {
|
override fun whenBrowserConfigured(body: KotlinJsBrowserDsl.() -> Unit) {
|
||||||
if (browserLazyDelegate.isInitialized()) {
|
if (browserLazyDelegate.isInitialized()) {
|
||||||
browser(body)
|
browser(body)
|
||||||
|
|||||||
Reference in New Issue
Block a user