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