[Gradle, JS] NodeJs and browser producing handlers
This commit is contained in:
+8
-3
@@ -32,11 +32,16 @@ open class KotlinBrowserJsIr @Inject constructor(target: KotlinJsIrTarget) :
|
|||||||
|
|
||||||
private lateinit var buildVariants: NamedDomainObjectContainer<BuildVariant>
|
private lateinit var buildVariants: NamedDomainObjectContainer<BuildVariant>
|
||||||
|
|
||||||
private val producingConfiguredHandlers: MutableList<KotlinBrowserJsIr.() -> Unit> = mutableListOf()
|
|
||||||
|
|
||||||
override val testTaskDescription: String
|
override val testTaskDescription: String
|
||||||
get() = "Run all ${target.name} tests inside browser using karma and webpack"
|
get() = "Run all ${target.name} tests inside browser using karma and webpack"
|
||||||
|
|
||||||
|
override fun configure() {
|
||||||
|
super.configure()
|
||||||
|
browserProducingConfiguredHandlers.forEach { handler ->
|
||||||
|
handler(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun configureDefaultTestFramework(it: KotlinJsTest) {
|
override fun configureDefaultTestFramework(it: KotlinJsTest) {
|
||||||
it.useKarma {
|
it.useKarma {
|
||||||
useChromeHeadless()
|
useChromeHeadless()
|
||||||
@@ -209,7 +214,7 @@ open class KotlinBrowserJsIr @Inject constructor(target: KotlinJsIrTarget) :
|
|||||||
if (producingConfigured) {
|
if (producingConfigured) {
|
||||||
this.body()
|
this.body()
|
||||||
} else {
|
} else {
|
||||||
producingConfiguredHandlers += body
|
browserProducingConfiguredHandlers += body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -38,7 +38,10 @@ abstract class KotlinJsIrSubTarget(
|
|||||||
|
|
||||||
protected val producingConfigured: Boolean = false
|
protected val producingConfigured: Boolean = false
|
||||||
|
|
||||||
private fun configure() {
|
protected val browserProducingConfiguredHandlers: MutableList<KotlinBrowserJsIr.() -> Unit> = mutableListOf()
|
||||||
|
protected val nodejsProducingConfiguredHandlers: MutableList<KotlinNodeJsIr.() -> Unit> = mutableListOf()
|
||||||
|
|
||||||
|
protected open fun configure() {
|
||||||
NpmResolverPlugin.apply(project)
|
NpmResolverPlugin.apply(project)
|
||||||
|
|
||||||
configureBuildVariants()
|
configureBuildVariants()
|
||||||
|
|||||||
+8
-3
@@ -17,10 +17,15 @@ open class KotlinNodeJsIr @Inject constructor(target: KotlinJsIrTarget) :
|
|||||||
override val testTaskDescription: String
|
override val testTaskDescription: String
|
||||||
get() = "Run all ${target.name} tests inside nodejs using the builtin test framework"
|
get() = "Run all ${target.name} tests inside nodejs using the builtin test framework"
|
||||||
|
|
||||||
private val producingConfiguredHandlers: MutableList<KotlinNodeJsIr.() -> Unit> = mutableListOf()
|
|
||||||
|
|
||||||
private val runTaskName = disambiguateCamelCased("run")
|
private val runTaskName = disambiguateCamelCased("run")
|
||||||
|
|
||||||
|
override fun configure() {
|
||||||
|
super.configure()
|
||||||
|
nodejsProducingConfiguredHandlers.forEach { handler ->
|
||||||
|
handler(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun runTask(body: NodeJsExec.() -> Unit) {
|
override fun runTask(body: NodeJsExec.() -> Unit) {
|
||||||
(project.tasks.getByName(runTaskName) as NodeJsExec).body()
|
(project.tasks.getByName(runTaskName) as NodeJsExec).body()
|
||||||
}
|
}
|
||||||
@@ -47,7 +52,7 @@ open class KotlinNodeJsIr @Inject constructor(target: KotlinJsIrTarget) :
|
|||||||
if (producingConfigured) {
|
if (producingConfigured) {
|
||||||
this.body()
|
this.body()
|
||||||
} else {
|
} else {
|
||||||
producingConfiguredHandlers += body
|
nodejsProducingConfiguredHandlers += body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user