What's the right way to integrate Grunt into a Spring/Gradle build?
gradle, gruntjs, javascript, spring
Solution
Files generated as part of the build shouldn't go into `src`, but somewhere under the `build` directory (say `build/grunt`). What's left is to include them in archives as necessary. For example:
war.dependsOn(grunt)
war {
from "build/grunt"
}
Or, if the Grunt task declares it outputs:
war {
from grunt
}
Problem
I have a Spring Boot project that is built with Gradle. All my front-end code lives under `src/main/resources/static`. This also includes my `bower_components`, `node_modules` (for Grunt tasks), etc. Right now, I have my main Gradle build script exec the Grunt build, which concatenates/minifies all my JavaScript, and they go under `src/main/resources/static/dist`. Then, when `processResources` gets executed in Gradle, the entire `src/main/resources/static/dist` gets copied to the build directory. This doesn't seem right to me - the only stuff that should end up in the build directory are the concatenated/minified JS, CSS, HTML and images. I've searched high and low but haven't found any clear direction here. Is there a best practice for building a project in this way?