Skip to content

Instantly share code, notes, and snippets.

@skhatri
Created January 30, 2014 00:08
Show Gist options
  • Save skhatri/8699973 to your computer and use it in GitHub Desktop.
Save skhatri/8699973 to your computer and use it in GitHub Desktop.
Grunt create war file using compress and rename.
var app = {
build: 'build',
root: '',
dist: 'build/dist'
};
grunt.initConfig({
app: app,
//create a war file in zip format. compress does not support it currently.
compress: {
war: {
options: {
archive: '<%=app.build%>/app.war.zip'
},
files: [
{expand: true, cwd: '<%=app.root%>', src: ['WEB-INF/web.xml'], dest: ''},
{expand: true, cwd: '<%=app.dist%>', src: ['**/*'], dest: ''}
]
}
},
//rename war.zip to war
rename: {
war: {
files: [
{src: ['<%=app.build%>/app.war.zip'], dest: '<%=app.build%>/app.war'}
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-rename');
grunt.registerTask('war', ['compress:war', 'rename:war']);
//run grunt war
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment