jeudi 19 février 2009

How to speed up the GWT compilation without modifying the UserAgent.xml etc...

If you search on the web a way to reduce the compilation time of you GWT application you would find many results !

Some articles explain that you can use the permutation configuration to compile a french application for IE6 for instance and not a french-english-deutsch-and-so application for firefoxilla-ie6-opera-andso !

They explain also that you can easily modify the UserAgent.xml and the I18N.gwt.xml files from the GWT distribution to set the locale and user agent you want to use to compile...

Unfortunatly, if I ask to my BOSS if I can modify those files and create a "GWT-1.5.3-with-my-funny-modification-to-reduce-compilation" distribution, I think he would kill and fired me for non quality suggestion and silly way so solve problem ! (Sorry guys, just kidding)

Here is some results sample :

If you read these articles, they explain how to reduce the compilation but you have to modify your module xml file also and if you use continuous integration you would have a only frenchy-firefoxed application for instance after the continuum/hudson build !!!

But if you RTFM you would find this page "Defining a Module: the Module XML File" and in this paragraph "Renaming modules" :
The <module> element supports an optional attribute rename-to that causes
the compiler to behave as though the module had the name specified. Renaming a
module has two primary use cases:

* to have a shorter module name that doesn't reflect the actual package structure
* to create a "working module" to speed up development time by restricting the
number of permutations

<module rename-to="">
<inherits name="" />
<set-property name="user.agent" value="ie6" />
<set-property name="locale" value="default" />

When WorkingModule.gwt.xml is compiled, the compiler will produce only an ie6
variant using the default locale; this will speed up development compilations.
The output from the WorkingModule.gwt.xml will be a drop-in replacement for MyModule.gwt.xml
because the compiler will generate the output using the alternate name.

To use a renamed module in hosted mode, it is necessary to use the "physical" name
(i.e. in the URL path, while otherwise referring to in the host HTML page.

So do you still need to modify google GWT distribution file to provide your own distribution ? Maybe if you use the -noserver option and GWT 1.5.3

Just create a new file called myDevModule.xml :

<module rename-to="">
<inherits name="" />
<set-property name="user.agent" value="ie6" />
<set-property name="locale" value="default" />

On my project, this solution is a very good news ! I can now compile in less than 2 minutes !!! A few days ago, I needed to wait for 10 minutes to compile on my computer...

But in the next GWT 1.6 release we will have a new way too avoid wasting time with compilation because the Draft Compile flag will become a real option and not only a patch (I Hope)

Hope that help !

PS: This trick does not work with the -noserver option... see this post on google group :
Here is the issue :

1 commentaire:

  1. Hey, that DO works !
    Thanks for the tip, you just saved me a couple hours a week :)