Giter VIP home page Giter VIP logo

gulp-war's People

Contributors

antonkudris-triptop avatar domderen avatar greenkeeperio-bot avatar pdehaan avatar scottweinstein avatar typhlosaurus avatar

Stargazers

 avatar

Watchers

 avatar  avatar

gulp-war's Issues

Use links (symlink/hardlink) instead of copying files to improve performance.

The contents of the WAR can be streamed directly into a final zipped WAR file. However, when debugging it is useful to utilized the exploded contents of a WAR instead. This means copying all the files from src/main/webapp into something like target/MyWebApp along with creating the zipped WAR file. This can be a time consuming task when there are many Javascript files.

Enhance war plugin to also zip the contents of the incoming stream.

The war plugin should zip the contents of the incoming stream, saving the results to a target value in the .dest() directory. This is what a WAR task does to begin with. There can be Validation of the WAR file via this plugin, and possibly a rearrangement of files.

Copy/Link node_modules into the WAR based on package.json

Often times a project cannot use Browserify nor Webpack. This results in a WAR file containing ALL the Javascript, CSS and HTML files needed to run the application. As there is no current way to easily run a Servlet Engine AND use the node_modules directory on a production machine, it becomes necessary to copy the static javascript library files into the WAR file (exploded or not).

This issue is to address the need to use node_modules modules within a web app via a loader such as RequireJS or Dojo. Or even directly loading the files via script tags. It would be great if a gulp task could determine the required dependencies, then copy or link them into the exploded WAR directory, then finally into the .WAR.

This is a scenario I currently face and updated vinyl-fs to support my needs. Having more specific web app tasks could be helpful.

var war    = require('gulp-war'),
    deps   = require('gulp-war/deps'); // or break out into gulp-npm-deps

// Quick Version
gulp.task('war', function () {
    gulp.src(["src/main/webapp/**"], { base: "src/main/webapp" })
        // Inject additional files into the stream via the package.json dependencies list.        
        .pipe(deps({
            source: "package.json", // [default] Does this make sense?
            sourceSelector: ["dependencies"], // [default] Does this make sense?
            // sourceSelector: ["dependencies", "devDependencies"] // Include all dependencies
            targetPath: "static/js", 
            // targetPath: "WEB-INF/static/js",
            // Exclude certain globs from the node_modules/dependencies list.
            exclude: ["**/docs", "uselessdep", "otherlib/src"]
        }))
        .pipe(war({
            target: "MyWebApp.war"
        })
        .pipe(gulp.dest("target"));
});

Create sub-plugin to add/autocreate web.xml and inject into current stream

Extract the creation of the web.xml file from the current plugin and allow it to be injected into the current stream.

Until there is a way to intelligently determine the contents of the web.xml file there isn't much sense in this plugin for now. A web.xml file should be in every JEE web app to begin with. If there isn't one, then the servers cannot infer any information about the contents of the .war file. Generating a default web.xml doesn't appear to have many use cases unless there was a way to template the file and then insert dynamic servlets or welcome files.

Example:

var war         = require('gulp-war'),
    warwebxml   = require('gulp-war/web-xml');

// Quick Version
gulp.task('war', function () {
    gulp.src(["src/main/webapp/**"], { base: "src/main/webapp" })
        .pipe(webxml({
            displayName: "My WebApp"
        })
        .pipe(war({
            target: "MyWebApp.war"
        })
        .pipe(gulp.dest("target"));
});

// Complicated Version
gulp.task('war', function () {
    gulp.src(["src/main/webapp/**"], { base: "src/main/webapp" })
        // Does this plugin make any sense? Why would a build process ever generate
        // this file? It would seem more suitable if there was a way to feed this plugin
        // a list of available Servlets which had been annotated. But the spec already handles this. 
        .pipe(webxml({
           // [Optional]
           version: "3.0", // Validate the config based on the version used.
           // [Required]
           displayName: "My WebApp",
           // [Optional]
           description: "My Description",           
           // [Optional]
           welcome: [
                "index",
                "welcome"
           ],
           // Perhaps this can be derived via some Annotations in the Java Code.
           // [Optional]
           servlets: [{
             name: 'dispatcher',
             displayName: 'MyDispatcher',
             pattern: '/*',
             class: 'org.foo.MyServlet',
             loadOnStartup: "0",
             initParams: [
               "bgColor": "#FFFFFF"
             ]
           }]
         }))
        .pipe(war({
            displayName: 'Grunt WAR',
            type: "war",
            target: 'MyWebApp' 
        }))
        .pipe(gulp.dest("target"));
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.