Background: I have a multi-project Gradle layout, and I defined a Gradle task that runs JavaScript unit tests in the Exec task. The inputs to this task are JavaScript files in the project, so they are restarted only when one of the source files changes. The task is added to all JavaScript projects from the main project.
Question: I want to expand this so that the tests can be re-run if the JavaScript files in the project or in any of its dependencies between the projects are changed. What is the best way to do this?
The code below works if it is placed in each subproject assembly file (after the dependency declaration), but we have 20+ JavaScript subprojects, and I would like to remain DRY.
project.ext.jsSourceFiles = fileTree("src/").include("**/*.js*") task testJavaScript(type: Exec, dependsOn: configurations.js) { inputs.files resolveJavascriptDependenciesFor(project) outputs.file "report.xml" // Run tests in JSTestDriver using command line call... } def resolveJavascriptDependenciesFor(project) { def files = project.jsSourceFiles project.configurations.js.allDependencies.each { files = files + resolveJavascriptDependenciesFor(it.dependencyProject) } return files }
Is there a better solution? Maybe where I do not need to solve all the file dependencies on my own?
source share