Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andrewfinnell opened this issue Oct 19, 2016 · 0 comments

Comments

@andrewfinnell
Copy link
Member

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"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant