Skip to content

Commit

Permalink
build(web-app-template): Use typed tasks
Browse files Browse the repository at this point in the history
Create variables for task instances for type safety and nicer syntax.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 28, 2024
1 parent 8b0b991 commit 28a26c3
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions plugins/reporters/web-app-template/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,48 +73,46 @@ tasks.addRule("Pattern: yarn<Command>") {
* Further configure rule tasks, e.g. with inputs and outputs.
*/

tasks {
"yarnInstall" {
description = "Use Yarn to install the Node.js dependencies."
group = "Node"
val yarnInstall = tasks.named("yarnInstall") {
description = "Use Yarn to install the Node.js dependencies."
group = "Node"

dependsOn(kotlinYarnSetup)
dependsOn(kotlinYarnSetup)

inputs.files(".yarnrc", "package.json", "yarn.lock")
inputs.files(".yarnrc", "package.json", "yarn.lock")

// Note that "node_modules" cannot be cached due to symlinks, see https://github.com/gradle/gradle/issues/3525.
outputs.dir("node_modules")
}
// Note that "node_modules" cannot be cached due to symlinks, see https://github.com/gradle/gradle/issues/3525.
outputs.dir("node_modules")
}

"yarnBuild" {
description = "Use Yarn to build the Node.js application."
group = "Node"
val yarnBuild = tasks.named("yarnBuild") {
description = "Use Yarn to build the Node.js application."
group = "Node"

inputs.files(project.tasks["yarnInstall"].outputs.files)
inputs.dir("src")
inputs.files(yarnInstall)
inputs.dir("src")

outputs.cacheIf { true }
outputs.dir("build")
}
outputs.cacheIf { true }
outputs.dir("build")
}

"yarnLint" {
description = "Let Yarn run the linter to check for style issues."
group = "Node"
val yarnLint = tasks.named("yarnLint") {
description = "Let Yarn run the linter to check for style issues."
group = "Node"

dependsOn("yarnInstall")
}
dependsOn(yarnInstall)
}

/*
* Resemble the Java plugin tasks for convenience.
*/

tasks.register("build") {
dependsOn(listOf("yarnBuild", "yarnLint"))
dependsOn(yarnBuild, yarnLint)
}

tasks.register("check") {
dependsOn("yarnLint")
dependsOn(yarnLint)
}

tasks.register<Delete>("clean") {
Expand Down

0 comments on commit 28a26c3

Please sign in to comment.