I am creating test apps. I need to upload them to remote server so the generated war size is important. The test apps mostly donot use plugins. Even after removing all default plugins the generated war is 20 mb. Is there a way to reduce the war file further? I am using grails 2.2. I am guessing there are many things in the war which are not needed. I appreciate any help. Thanks!
2 Answers
Even after removing all default plugins the generated war is 20 mb. Is there a way to reduce the war file further? I am using grails 2.2.
It is impossible to say if there is more in the .war
file that could be removed or not without knowing what your application is doing and which libraries are actually being used. Look at the .jar
files that are in your .war
file and if there are ones that you don't need they can be excluded. See https://grails.github.io/grails2-doc/2.2.x/guide/conf.html#ivy for info on excluding transitive dependencies.

- 26,804
- 2
- 30
- 47
If I were you I would look into upgrading to Grails 4 or maybe looking into Micronaut. Grails generally is optimised for the speed of development, in operating s lot of libraries, and using convention over configuration. That being said you might get some gains going to Grails 4 as many refactors have happened, and some older dependencies have been removed. Also Grails 4 uses Micronaut as it's parent context making start up time faster. Grails 3 and 4 generally also consume less memory. The effort to upgrade to Grails 3 is a function of: How many bad practices you have * the amount of code you have
So upgrading to Grails 3 is non trivial, although consider how small your app is it might not be that bad. Upgrading form 3 to 4 is a lot more straight forward. Going from 2 to 4 would be a little more than the effort of going from 2 to 3, but again if you're app is really small it might not be that bad.
Micronaut on the other hand was made for micro services, and has an all around smaller footprint. You can still use Groovy with it and while it does share some coming traits with Grails, it doesn't use convention over configuration, and looks more like spring boot with a lot of annotations.

- 462
- 3
- 12
-
In that case Jeff's answer is the way to go, although 20MB is small compared to any non trivial Grails app I've seen. Good luck. Maybe some day you can force the upgrade to Grails 4.1 when it comes out to work on Java 11, as a compliance thing. – virtualdogbert May 13 '20 at 19:13