From 52f64d1ab3592ec9b17eab45b0d5260444f69834 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 21 Aug 2015 19:23:24 +0200 Subject: [PATCH] Integration of the Grunt-Frontend- with the Maven-Backend-Project --- .gitignore | 3 +- Gruntfile.js | 34 ++++++++ package.json | 12 +++ pom.xml | 49 ++++++++++- src/main/frontend/html/layout.html | 12 +-- .../webapp/thymeleaf/templates/layout.html | 87 ------------------- 6 files changed, 102 insertions(+), 95 deletions(-) create mode 100644 Gruntfile.js create mode 100644 package.json delete mode 100644 src/main/webapp/thymeleaf/templates/layout.html diff --git a/.gitignore b/.gitignore index be8c7ad..28dba0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target -src/main/frontend/node_modules +node +**/node_modules src/main/frontend/dist diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..d1d5acc --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,34 @@ +module.exports = function(grunt) { + + grunt.loadNpmTasks('grunt-newer'); + + grunt.registerTask('frontend','Build HTML & CSS for Frontend', function() { + var + done = this.async(), + path = './src/main/frontend'; + + grunt.util.spawn({ + cmd: 'npm', + args: ['install'], + opts: { cwd: path, stdio: 'inherit' } + }, function (err, result, code) { + if (err || code > 0) { + grunt.fail.warn('Failed installing node modules in "' + path + '".'); + } + else { + grunt.log.ok('Installed node modules in "' + path + '".'); + } + + process.chdir(path); + require(path + '/Gruntfile.js')(grunt); + grunt.task.run('newer:copy'); + grunt.task.run('newer:less'); + + done(); + }); + }); + + + grunt.registerTask('default', [ 'frontend' ]); + +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..81fefa0 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "maven-grunt-integration", + "description": "Example, how to ingegrat maven with a frontend developed with Grunt", + "homepage": "http://juplo.de/maven-grunt-integration", + "author": "kai@juplo.de", + "version": "1.0.0", + "devDependencies": { + "grunt": "~0.4.5", + "grunt-cli": "~0.1.13", + "grunt-newer": "~1.1.1" + } +} diff --git a/pom.xml b/pom.xml index 3cb5566..243cbf8 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ de.juplo maven-grunt-integration Juplo - Example Integration of Maven and Grunt - 0.1 + 1.0.0 war http://www.juplo.de/maven-grunt-integration @@ -134,6 +134,18 @@ true + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + + src/main/frontend/dist + + + + org.apache.maven.plugins maven-source-plugin @@ -153,9 +165,44 @@ jetty-maven-plugin 9.2.13.v20150730 + + + src/main/frontend/dist + src/main/webapp + + true + + com.github.eirslett + frontend-maven-plugin + 0.0.24 + + + install node and npm + + install-node-and-npm + + + v0.10.18 + 1.3.8 + + + + npm install + + npm + + + + grunt build + + grunt + + + + diff --git a/src/main/frontend/html/layout.html b/src/main/frontend/html/layout.html index be958d5..1e84a84 100644 --- a/src/main/frontend/html/layout.html +++ b/src/main/frontend/html/layout.html @@ -1,5 +1,5 @@ - + @@ -7,21 +7,21 @@ - Layout-Template + Layout-Template - +
-

yourSHOUTER - Startseite

+

yourSHOUTER - Startseite