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?
Gradle and Grunt are primarily classified as "Java Build" and "JS Build Tools / JS Task Runners" tools respectively. "Flexibility" is the primary reason why developers consider Gradle over the competitors, whereas "Configuration " was stated as the key factor in picking Grunt.
Gradle is a general-purpose build tool Gradle makes it easy to build common types of project — say Java libraries — by adding a layer of conventions and prebuilt functionality through plugins. You can even create and publish custom plugins to encapsulate your own conventions and build functionality.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With