最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What's the right way to integrate Grunt into a SpringGradle build? - Stack Overflow

programmeradmin3浏览0评论

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_ponents, 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?

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_ponents, 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?

Share asked Feb 23, 2014 at 22:08 Joe AttardiJoe Attardi 4,5213 gold badges41 silver badges43 bronze badges 2
  • This seems like a good setup. Would you share your gradle and bower configuration? – Bahadır Yağan Commented Jan 31, 2015 at 14:19
  • 1 I've actually changed my setup pletely from last year. I'm using Gulp now, and everything goes into my build directory - not in src. If you're still curious about my setup, you can see the project here: github./joeattardi/tailstreamer/tree/develop – Joe Attardi Commented Feb 4, 2015 at 15:33
Add a ment  | 

1 Answer 1

Reset to default 5

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
}
发布评论

评论列表(0)

  1. 暂无评论