parlew / gulp-war Goto Github PK
View Code? Open in Web Editor NEWThis project forked from scottweinstein/gulp-war
Gulp plugin for Java WAR file generation
License: MIT License
This project forked from scottweinstein/gulp-war
Gulp plugin for Java WAR file generation
License: MIT License
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.
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.
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"));
});
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"));
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.