[Gradle, JS] Allow to create another binaries.executable

#KT-KT-38055 fixed
This commit is contained in:
Ilya Goncharov
2020-04-06 19:42:49 +03:00
parent 6a02e257a0
commit 57b99bbc0c
2 changed files with 30 additions and 15 deletions
@@ -97,25 +97,39 @@ constructor(
jsBinaryType: JsBinaryType, jsBinaryType: JsBinaryType,
create: (compilation: KotlinJsCompilation, name: String, type: KotlinJsBinaryType) -> T create: (compilation: KotlinJsCompilation, name: String, type: KotlinJsBinaryType) -> T
) { ) {
types.forEach { buildVariantKind -> types.forEach {
val name = generateBinaryName( createBinary(
compilation, compilation,
buildVariantKind, it,
jsBinaryType jsBinaryType,
create
) )
}
}
require(name !in binaryNames) { private fun <T : JsBinary> createBinary(
"Cannot create binary $name: binary with such a name already exists" compilation: KotlinJsCompilation,
} type: KotlinJsBinaryType,
jsBinaryType: JsBinaryType,
create: (compilation: KotlinJsCompilation, name: String, type: KotlinJsBinaryType) -> T
) {
val name = generateBinaryName(
compilation,
type,
jsBinaryType
)
binaryNames.add(name) if (name in binaryNames) {
return
}
val binary = create(compilation, name, buildVariantKind) binaryNames.add(name)
add(binary)
// Allow accessing binaries as properties of the container in Groovy DSL. val binary = create(compilation, name, type)
if (this is ExtensionAware) { add(binary)
extensions.add(binary.name, binary) // Allow accessing binaries as properties of the container in Groovy DSL.
} if (this is ExtensionAware) {
extensions.add(binary.name, binary)
} }
} }
@@ -57,8 +57,9 @@ abstract class KotlinJsIrSubTarget(
} }
} }
internal fun produceExecutable() { internal val produceExecutable: () -> Unit by lazy {
configureMain() configureMain()
return@lazy { Unit }
} }
override fun testTask(body: KotlinJsTest.() -> Unit) { override fun testTask(body: KotlinJsTest.() -> Unit) {