GWT modules handle the internationalization in a static manner. Unlike many web frameworks, GWT does not resolve internationalized strings at runtime but during the compilation phase. The compiler automatically replaces all the internationalized strings with their localized value. This produces a version of every script per supported locale.
Similarly, GWT produces web-browser-specific script versions of the module during compilation, i.e., one version per supported web browser.
The combination of a web browser and a language is called a permutation. Generally an end user will only need one of these permutations as he / she will access the web page with a single web browser using his/her default locale.
GWT’s approach has the benefit, for end users, to speed up the web application loading time, as only resources related to their locale and web browser will be downloaded and then displayed.
For instance a French user connecting to the GWT-built-web-page with Firefox will only load the gecko1_8/Fr permutation.
Let’s assume your module supports 3 languages (English, French and Spanish) and the 6 default web browser engines, i.e., IE6, IE8, gecko, gecko1_8 Opera and safari. It gives 3*6 = 18 permutations.
The compilation of the 18 permutations may be time consuming. The compilation time would increase as you may add support of new languages.
On a day to day basis, developers may not want to compile all the permutations. Generally one locale and one web browser is enough for testing purpose.
So the basic idea, to speed up the compilation time, is to reduce the number of compiled permutations.
Reduce the scope of the compilation to improve build time.
GWT provides a mechanism to set properties inside the module descriptor, i.e., the .gwt.xml file. We will use two properties that will help us to solve our problem: user.agent and locale. The user.agent property allows us to reduce the list of the supported web browsers to only one, e.g., FF (gecko1_8 web browser engine). The locale property allows us to set the only translation we need, e.g, English.You can create two different versions of your module descriptor, e.g., production.gwt.xml and development.gwt.xml. The first one, used by default, allows compilation of all the supported permutations (all browsers and all languages). The second one reduces the scope of compilation to a single locale and a single web browser by adding the following properties:
<set-property name="user.agent" value="gecko1_8" /> <set-property name="locale" value="en" />
Compile the module using a maven profile and the right module descriptor.
From now on you can specify maven profiles into your pom.xml to compile your module using the module descriptor that fits your needs. In the example below, profiles are activated by the use of a "skipPermutations" system property that can be set through the compilation command line:Developers can use the lightweight compilation while the continuous integration server can still build all permutations.mvn clean install -DskipPermutations=true
With such an approach, our team save multiple minutes per build.<profiles> <profile> <id>buildAllPermutations</id> <activation> <property> <name>!skipPermutations</name> </property> </activation> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <configuration> <module>production</module> <-- the module descriptor to use if the "skipPermutations" system property is not set or set to false </configuration> [...] </plugin> [...] <plugins></build> </profile> <profile> <id>buildASinglePermutation</id> <activation> <property> <name>skipPermutations</name> </property> </activation> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <configuration> <module>development</module> <-- the module descriptor to use if the "skipPermutations" system property is set to true </configuration> [...] </plugin> [...] <plugins> </build> </profile> </profiles>
Nicolas Chabanoles