Sebastian Schuberth
11/27/2024, 5:49 PMSebastian Schuberth
11/27/2024, 5:49 PMval generatedResourcesDir = layout.buildDirectory.dir("generated-resources/main")
val copyWebAppTemplate by tasks.registering(Copy::class) {
val webAppTemplateProject = project.project(projects.plugins.reporters.webAppTemplate.path)
dependsOn(webAppTemplateProject.tasks["yarnBuild"])
from(webAppTemplateProject.file("build")) {
include("scan-report-template.html")
}
into(generatedResourcesDir)
if (inputs.sourceFiles.isEmpty) throw StopExecutionException("No input files found.")
outputs.cacheIf { true }
}
Sebastian Schuberth
11/27/2024, 5:51 PMyarnBuild
task from the webAppTemplate
project, and copy its output HTML file as a resource into this project.Sebastian Schuberth
11/27/2024, 5:51 PM./gradlew -p plugins/reporters/web-app copyWebAppTemplate./gradlew -p plugins/reporters/web-app copyWebAppTemplate
gets me > No input files found.
Martin
11/27/2024, 5:54 PMMartin
11/27/2024, 5:55 PMSebastian Schuberth
11/27/2024, 5:57 PMMartin
11/27/2024, 5:58 PMMartin
11/27/2024, 6:00 PMVampire
11/27/2024, 6:23 PMVampire
11/27/2024, 6:23 PMVampire
11/27/2024, 6:23 PMSebastian Schuberth
11/27/2024, 9:17 PMSebastian Schuberth
11/27/2024, 9:20 PMval webAppTemplateConfiguration by configurations.creating {
isCanBeResolved = false
}
artifacts {
add(webAppTemplateConfiguration.name, yarnBuild)
}
val yarnInstall by tasks.registering {
description = "Use Yarn to install the Node.js dependencies."
group = "Node"
dependsOn(kotlinYarnSetup)
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")
}
val yarnBuild by tasks.registering {
description = "Use Yarn to build the Node.js application."
group = "Node"
inputs.files(yarnInstall)
inputs.dir("src")
outputs.cacheIf { true }
outputs.dir("build")
}
and the consumer has
val webAppTemplateConfiguration by configurations.creating {
isCanBeConsumed = false
}
dependencies {
webAppTemplateConfiguration(project(":plugins:reporters:web-app-template", "webAppTemplateConfiguration"))
}
val generatedResourcesDir = layout.buildDirectory.dir("generated-resources/main")
val copyWebAppTemplate by tasks.registering(Copy::class) {
val webAppTemplate: FileCollection = webAppTemplateConfiguration
inputs.dir(webAppTemplate)
from(webAppTemplate) {
include("scan-report-template.html")
}
into(generatedResourcesDir)
outputs.cacheIf { true }
}
but executing copyWebAppTemplate
does not execute yarnBuild
.Sebastian Schuberth
11/27/2024, 9:24 PMSebastian Schuberth
11/27/2024, 10:00 PMtasks.registering
was wrong in my case as my yarn
tasks are generated by a task rule. I'm now using tasks.named()
instead to refine configuration of those tasks.