Dark theme | Light theme

May 31, 2009

Create a much smaller Grails WAR file without JAR files

The size of a normal Grails WAR file is at least 20MB. The reason is the big list of JAR files which are included in the WEB-INF/lib directory. To exclude all JAR files from the WAR file we can use the command-line argument -nojars. This will even exclude JAR files provided by Grails plugins. The complete command to create the WAR file is:

$ grails war -nojars

We now have a much smaller WAR file (about 200KB for an empty Grails application): a skinny war. This scenario is useful if for example our upload speed is slow. Uploading 20MB can take up to minutes with an ASDL connection. So for a first deployment we can upload the complete WAR file, but for following deployments we can use the small WAR file. Of course we must keep in mind we didn't add new plugins to the application with JAR files, because they will not be added to the WAR file.