[Gradle, JS] Run task for library
^KT-41566 fixed
This commit is contained in:
+1
-1
@@ -200,7 +200,7 @@ abstract class KotlinJsIrSubTarget(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun configureLibrary(compilation: KotlinJsIrCompilation) {
|
protected open fun configureLibrary(compilation: KotlinJsIrCompilation) {
|
||||||
val project = compilation.target.project
|
val project = compilation.target.project
|
||||||
|
|
||||||
val processResourcesTask = target.project.tasks.named(compilation.processResourcesTaskName)
|
val processResourcesTask = target.project.tasks.named(compilation.processResourcesTaskName)
|
||||||
|
|||||||
+27
-6
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsNodeDsl
|
|||||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec
|
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
||||||
import org.jetbrains.kotlin.gradle.tasks.dependsOn
|
import org.jetbrains.kotlin.gradle.tasks.dependsOn
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -37,15 +38,25 @@ open class KotlinNodeJsIr @Inject constructor(target: KotlinJsIrTarget) :
|
|||||||
.getIrBinaries(KotlinJsBinaryMode.DEVELOPMENT)
|
.getIrBinaries(KotlinJsBinaryMode.DEVELOPMENT)
|
||||||
.matching { it is Executable }
|
.matching { it is Executable }
|
||||||
.all { developmentExecutable ->
|
.all { developmentExecutable ->
|
||||||
val runTaskHolder = NodeJsExec.create(compilation, disambiguateCamelCased(RUN_TASK_NAME)) {
|
configureRun(compilation, developmentExecutable)
|
||||||
group = taskGroupName
|
|
||||||
inputFileProperty.set(developmentExecutable.linkTask.flatMap { it.outputFileProperty })
|
|
||||||
}
|
|
||||||
|
|
||||||
target.runTask.dependsOn(runTaskHolder)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun configureRun(compilation: KotlinJsIrCompilation, binary: JsIrBinary) {
|
||||||
|
val name = disambiguateCamelCased(RUN_TASK_NAME)
|
||||||
|
val runTask = project.locateTask<NodeJsExec>(name)
|
||||||
|
if (runTask != null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val runTaskHolder = NodeJsExec.create(compilation, name) {
|
||||||
|
group = taskGroupName
|
||||||
|
inputFileProperty.set(binary.linkTask.flatMap { it.outputFileProperty })
|
||||||
|
}
|
||||||
|
|
||||||
|
target.runTask.dependsOn(runTaskHolder)
|
||||||
|
}
|
||||||
|
|
||||||
override fun configureBuild(
|
override fun configureBuild(
|
||||||
compilation: KotlinJsIrCompilation
|
compilation: KotlinJsIrCompilation
|
||||||
) {
|
) {
|
||||||
@@ -56,4 +67,14 @@ open class KotlinNodeJsIr @Inject constructor(target: KotlinJsIrTarget) :
|
|||||||
project.tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(productionExecutable.linkTask)
|
project.tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(productionExecutable.linkTask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun configureLibrary(compilation: KotlinJsIrCompilation) {
|
||||||
|
super.configureLibrary(compilation)
|
||||||
|
compilation.binaries
|
||||||
|
.getIrBinaries(KotlinJsBinaryMode.DEVELOPMENT)
|
||||||
|
.matching { it is Library }
|
||||||
|
.all { binary ->
|
||||||
|
configureRun(compilation, binary)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user