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 :

http://vinaytech.wordpress.com/2008/11/10/gwt-compiler-compiling-for-...

http://blog.bazoud.com/post/2008/07/31/Can-I-speed-up-the-GWT-compiler
http://blog.bazoud.com/post/2008/07/31/Can-I-speed-up-the-GWT-compile...
http://blog.bazoud.com/post/2008/07/31/Can-I-speed-up-the-GWT-compile...

http://www.youenchene.fr/2008/08/petite-astuce-pour-gwt.html

http://www.ongwt.com/post/2008/08/11/How-do-speed-up-the-GWT-compiler

http://www.scribd.com/doc/9692542/How-to-Speedup-Gwt-Compiler

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

com.foo.WorkingModule.gwt.xml:

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

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. com.foo.WorkingModule) in the URL path, while otherwise referring to
com.foo.MyModule 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="com.foo.MyModule">
<inherits name="com.foo.MyModule" />
<set-property name="user.agent" value="ie6" />
<set-property name="locale" value="default" />
</module>

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 : http://groups.google.fr/group/Google-Web-Toolkit/browse_thread/thread/38ff8bedd038ec68?q=Manage+developement+and+production+environnement#beff4307165969c7
Here is the issue : http://code.google.com/p/google-web-toolkit/issues/detail?id=2976

1 commentaire:

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

    RépondreSupprimer