-
Notifications
You must be signed in to change notification settings - Fork 11
How to use grunt war with yeoman project
Yeoman is a webapp generator using tools like Yo, Grunt or Bower... You can find more on it on their website : http://yeoman.io/
The purpose of this page is to explain how to use grunt-war with it in order to generate a war file.
You just need to enter the following command in your project folder :
npm install grunt-war --save-dev
Now open your gruntfile.js and add this line:
grunt.loadNpmTasks('grunt-war');
like this :
module.exports = function (grunt) {
/*
* Some configuration setting
*/
//Grunt WAR --- Add this line
grunt.loadNpmTasks('grunt-war');
/*
* ...
*/
grunt.initConfig({
/*
* Where we add the configuration (see next step)
*/
Don't close your editor yet we are getting to the hard part.
Now we need to add the war directives for the creation of the file :
grunt.loadNpmTasks('grunt-war');
grunt.initConfig({
/*
* Build a WAR (web archive) without Maven or the JVM installed.
*/
war: {
target: {
options: {
war_dist_folder: '<%= yeoman.dist %>', //Where you have your yeoman build files
war_verbose: true,
war_name: 'mytodo', //the name of your war
webxml_welcome: 'index.html',
webxml_display_name: 'My Todo List',
webxml_mime_mapping: [ //some settings that you want to appear in your web.xml file
]
},
files: [
{
expand: true,
cwd: '<%= yeoman.dist %>', //Where you have your yeoman build files
src: ['**'],
dest: '.'
}
]
}
}
/*
* More lines ....
*/
};
In your project folder (where there is your gruntfile.js), enter this command :
grunt build
If everything goes correctly you should have a dist
folder with all the files needed to run you webapp.
No still, in your project folder (where there is your gruntfile.js), run the command :
grunt war
Now go in your dist
folder, you should see a .war
file with the name that you choose in your gruntfile.
Hope this will help