Hello,
We’ve broken up our base build.gradle into multiple gradle files for ease of maintenance. The general setup is this:
build.gradle
subproject-all.gradle
subproject-java.gradle
(etc etc)
In build.gradle, there is then a section that looks like so:
project.ext.nonJavaProjects = [/* names */]
// ...
subprojects {
apply from: '../master/subproject-all.gradle'
}
configure(subprojects.findAll { !nonJavaProjects.contains(it.name)}) {
apply from: '../master/subproject-java.gradle'
}
We moved to gradle from an older code base, and we haven’t had an opportunity to update the directory layout for easy configuration. Anyway, I’ve tried to add the javascript plugin, so I’ve added a new “js.gradle” file:
apply plugin: 'js'
project.ext.jsBuildDir = "build/js"
project.ext.jsReportDir = "build/reports/js/"
project.ext.jsHintOptions = [ ... ]
jshint.options = jsHintOptions
// Try to apply some configuration across all tasks of jsHint type
tasks.withType(com.eriwen.gradle.js.tasks.JsHintTask) {
outputToStdOut = true
}
Every project that “applies from: ‘js.gradle’” then gets common configuration. Now, here’s the funny part I can’t explain - configuring the tasks to turn on “outputToStdOut” works without error, but the tasks declared in the project never get this setting. But if I move that block in the main build.gradle file (under subproject configuration) or the project itself, then it works correctly.
So alternatively, this works:
subprojects {
apply from: '../master/subproject-all.gradle'
apply from: '../master/js.gradle'
// Moved from js.gradle
tasks.withType(com.eriwen.gradle.js.tasks.JsHintTask) {
outputToStdOut = true
}
}
I’m wondering why the task configuration doesn’t work inside js.gradle? I should note that, as a 3rd party plugin, I needed to import the plugin in buildscript; js.gradle needed it’s own buildscript block for importing as well, so I suspect it has something to do with scoping, but I’m scratching my head.