0

I am interested in minifying and concatenating the css and js files of my application. I am able to automate this with gulp, as outlined in this tutorial:

https://travismaynard.com/writing/getting-started-with-gulp

I am using netbeans to generate the .war file of my project for deployment (right click project --> clean and build). At the moment, gulp simply generates the files to a folder in the build directory. And obviously, the .war file that I generate doesn't include these files. I was wondering how I can have the generated .war file include the files that I generate with gulp (which can be found at say: /my_project/build/web/js or /my_project/build/web/css). Currently, gulp "watches" for a change in the js or css files, but I would be fine with just calling the gulp tasks once (when the .war is generated).

Would I need to make changes to my build.xml file? Do I need a different way of minimizing these files (eg: minimize and concat once deployed)?

Thanks.

theyuv
  • 1,556
  • 4
  • 26
  • 55
  • This is a bit outdated, however when searching for WAR and Gulp this is the top hit. Read through my post on the 'gulp-war' task and see if it makes sense. If there is enough interested I intend on implementing the feature's I've discussed. https://github.com/ScottWeinstein/gulp-war/issues/6 – Andrew T Finnell Oct 19 '16 at 21:07

2 Answers2

0

Check this gulp package: https://www.npmjs.com/package/gulp-war You can create a gulp task where you can define the files to be included/excluded files. Sample

var war = require('gulp-war'),
    zip = require('gulp-zip'), 

.....

gulp.task('war', function () {
    gulp.src('./tmp/**')
        .pipe(war({
            welcome: 'index.html',
            displayName: "YOUR APP NAME",
        }))
        .pipe(zip('webapp.war'))
        .pipe(gulp.dest('./target/'));

});
PSA
  • 225
  • 1
  • 6
  • 11
-1

please try this :

https://github.com/eirslett/frontend-maven-plugin

Basically maven will call gulp to prepare some files, then generate a war for all of them

Justin
  • 1,050
  • 11
  • 26
  • Sadly this maven plugin makes life so much worse than just integrating gulp and maven properly. For example one can call npm install on the init phase, ./node_modules/.bin/gulp.cmd on generate-sources, etc. This plugin does very questionable things. It pretty makes npm, gulp and node_modules useless outside of maven. Instead of creating a .cache dir and using the real node_modules directory it creates everything under a new directory. meaning you duplicate everything if you need gulp outside of maven. I appreciate the effort on it but trust me when I say it'll hurt later. – Andrew T Finnell Oct 04 '16 at 22:05