[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,27 +97,41 @@ 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 {
createBinary(
compilation,
it,
jsBinaryType,
create
)
}
}
private fun <T : JsBinary> createBinary(
compilation: KotlinJsCompilation,
type: KotlinJsBinaryType,
jsBinaryType: JsBinaryType,
create: (compilation: KotlinJsCompilation, name: String, type: KotlinJsBinaryType) -> T
) {
val name = generateBinaryName( val name = generateBinaryName(
compilation, compilation,
buildVariantKind, type,
jsBinaryType jsBinaryType
) )
require(name !in binaryNames) { if (name in binaryNames) {
"Cannot create binary $name: binary with such a name already exists" return
} }
binaryNames.add(name) binaryNames.add(name)
val binary = create(compilation, name, buildVariantKind) val binary = create(compilation, name, type)
add(binary) add(binary)
// Allow accessing binaries as properties of the container in Groovy DSL. // Allow accessing binaries as properties of the container in Groovy DSL.
if (this is ExtensionAware) { if (this is ExtensionAware) {
extensions.add(binary.name, binary) extensions.add(binary.name, binary)
} }
} }
}
companion object { companion object {
internal fun generateBinaryName( internal fun generateBinaryName(
@@ -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) {