Gradle: provide descriptions for JS tasks

#KT-31560 Fixed
This commit is contained in:
Sergey Rostov
2019-05-31 14:43:58 +03:00
parent fbefa17337
commit 8dabf24b41
5 changed files with 17 additions and 1 deletions
@@ -35,6 +35,7 @@ class KotlinJsTarget(project: Project, platformType: KotlinPlatformType) :
val runTaskName get() = lowerCamelCaseName(disambiguationClassifier, runTaskNameSuffix)
val runTask
get() = project.tasks.maybeCreate(runTaskName).also {
it.description = "Run js on all configured platforms"
if (runTaskName != runTaskNameSuffix) {
project.whenEvaluated {
project.tasks.maybeCreate(runTaskNameSuffix).dependsOn(it)
@@ -90,7 +90,7 @@ class NpmSimpleLinker(val rootProject: Project) {
}
if (result.exitValue != 0) {
error("Cannot create window junctions: nodejs exited with ${result.exitValue}")
error("Cannot create windows junctions: nodejs exited with ${result.exitValue}")
}
}
}
@@ -19,6 +19,9 @@ class KotlinBrowserJs(target: KotlinJsTarget) :
KotlinJsSubTarget(target, "browser"),
KotlinJsBrowserDsl {
override val testTaskDescription: String
get() = "Run all ${target.name} tests inside browser using karma and webpack"
private val webpackTaskName = disambiguateCamelCased("webpack")
override fun configureDefaultTestFramework(it: KotlinJsTest) {
@@ -43,6 +46,7 @@ class KotlinBrowserJs(target: KotlinJsTarget) :
it.dependsOn(target.project.nodeJs.root.npmResolveTask, compileKotlinTask)
it.compilation = compilation
it.description = "build webpack bundle"
project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(it)
}
@@ -57,6 +61,7 @@ class KotlinBrowserJs(target: KotlinJsTarget) :
it.bin = "webpack-dev-server"
it.compilation = compilation
it.description = "start webpack dev server"
it.devServer = KotlinWebpackConfigWriter.DevServer(
open = true,
@@ -62,6 +62,8 @@ abstract class KotlinJsSubTarget(
}
}
abstract val testTaskDescription: String
private fun configureTests(compilation: KotlinJsCompilation) {
// apply plugin (cannot be done at task instantiation time)
val nodeJs = NodeJsPlugin.apply(target.project).root
@@ -70,6 +72,7 @@ abstract class KotlinJsSubTarget(
val compileTask = compilation.compileKotlinTask
testJs.group = LifecycleBasePlugin.VERIFICATION_GROUP
testJs.description = testTaskDescription
testJs.dependsOn(target.project.nodeJs.root.npmResolveTask, compileTask, nodeJs.nodeJsSetupTask)
@@ -19,6 +19,9 @@ class KotlinNodeJs(target: KotlinJsTarget) :
KotlinJsSubTarget(target, "node"),
KotlinJsNodeDsl {
override val testTaskDescription: String
get() = "Run all ${target.name} tests inside nodejs using the builtin test framework"
override fun runTask(body: NodeJsExec.() -> Unit) {
(project.tasks.getByName(runTaskName) as NodeJsExec).body()
}
@@ -30,7 +33,11 @@ class KotlinNodeJs(target: KotlinJsTarget) :
override fun configureRun(compilation: KotlinJsCompilation) {
val project = target.project
"true".toBoolean()
val runTaskHolder = project.createOrRegisterTask<NodeJsExec>(disambiguateCamelCased("run")) { runTask ->
runTask.description = "run compiled js in nodejs"
val compileKotlinTask = compilation.compileKotlinTask
runTask.dependsOn(target.project.nodeJs.root.npmResolveTask, compileKotlinTask)