Aug 18, 2011

Reducing GWT application compile time

After setting up gwt in eclipse and creating my first gwt project,  I saw the compiler output console shows :


Compiling 1 permutation
      Compiling permutation 0...
   Compile of permutations succeeded



 I was wondering what are these permutations ! Then I found out that gwt generates different versions of the application for different browsers and locales, as unfortunately browsers can behave differently. So it generates different version of the javascript for IE, firefox, safari etc. And if we are using internationalization, for example, 5 languages, then different versions for each language. So 5 locales and 3 browsers, that creates 15 different cases or in other words, 15 different permutations resulting more time for compilation. For development, this can be annoying, so just to check quick output, we can limit this to single permutation by mentioning just one browser or user - agent .  To do this, we need to mention which user - agent or browser we want it to compile for. We need to set the property in the gwt module file : < module-name >.gwt.xml .


< module rename-to='myproject'   >
< inherits name='com.google.gwt.user.User'  />
< set-property name="user.agent" value="gecko1_8"  />
...


In this case it only generates one version for firefox ( gecko1_8 is firefox :D ) and the compilation time reduces to tolerable limit for a developer.