Java, Ubuntu, ...

Aller au contenu | Aller au menu | Aller à la recherche

mardi 5 août 2008

GWT 1.5 RC2

GWT 1.5 RC2 vient tout juste de sortir. C'est téléchargeable ici : http://code.google.com/p/google-web-toolkit/downloads/list

jeudi 31 juillet 2008

How to speed up the GWT compiler ? (Part III)

English version

To speed up GWT compiler, the main idea is to reduce GWT permutations.

To manage the permutations, I build my own version of GWT 1.5 named GWT 1.5 r2030-olivier.

I am using 1.5 M1:

  • svn co http://google-web-toolkit.googlecode.com/svn/trunk -r2030
  • Edit I18N.gwt.xml to remove default locale and force "fr_FR" as "default" locale
Index: trunk/user/src/com/google/gwt/i18n/I18N.gwt.xml
===================================================================
--- trunk/user/src/com/google/gwt/i18n/I18N.gwt.xml     (revision 2030)
+++ trunk/user/src/com/google/gwt/i18n/I18N.gwt.xml     (working copy)
@@ -18,7 +18,7 @@
 
        <!-- Browser-sensitive code should use the 'locale' client property. -->
        <!-- 'default' is always defined.                                    -->
-       <define-property name="locale" values="default" />
+       <define-property name="locale" values="fr_FR" />
 
        <property-provider name="locale">
                <![CDATA[
  • Edit UserAgent.gwt.xml and, in my case, remove unused some browsers : safari, opera, gecko (old firefox/mozilla)
Index: trunk/user/src/com/google/gwt/user/UserAgent.gwt.xml
===================================================================
--- trunk/user/src/com/google/gwt/user/UserAgent.gwt.xml        (revision 2030)
+++ trunk/user/src/com/google/gwt/user/UserAgent.gwt.xml        (working copy)
@@ -19,7 +19,7 @@
 <module>
 
   <!-- Browser-sensitive code should use the 'user.agent' property -->
-  <define-property name="user.agent" values="ie6,gecko,gecko1_8,safari,opera"/>
+  <define-property name="user.agent" values="ie6,gecko1_8"/>
 
   <property-provider name="user.agent"><![CDATA[
       var ua = navigator.userAgent.toLowerCase();
@@ -27,11 +27,7 @@
           return (parseInt(result[1]) * 1000) + parseInt(result[2]);
       };
 
-      if (ua.indexOf("opera") != -1) {
-        return "opera";
-      } else if (ua.indexOf("webkit") != -1) {
-        return "safari";
-      } else if (ua.indexOf("msie") != -1) {
+      if (ua.indexOf("msie") != -1) {
         var result = /msie ([0-9]+)\.([0-9]+)/.exec(ua);
         if (result && result.length == 3) {
           if (makeVersion(result) >= 6000) {
@@ -44,7 +40,6 @@
           if (makeVersion(result) >= 1008)
             return "gecko1_8";
           }
-        return "gecko";
       }
       return "unknown";
   ]]></property-provider>

With my own build, GWT compiler speeds up my project compilation :

  • 12mn with GWT 1.5 r2030
  • 4mn with GWT 1.5 r2030-olivier
  • 1m15s with GWT 1.5 r2030-olivier + no additional locale
  • 1mn with GWT 1.5 r2030-olivier + no locale + gecko1_8

This is an amazing gain : 12mn to 1mn

French version

Coming soon.

How to speed up the GWT compiler ? (Part II)

English version

To speed up GWT compiler, the main idea is to reduce GWT permutations.

1. Force a browser

In your module.gwt.xml, force an user agent : gecko1_8 (Firefox 2).

    <!-- User Agent -->
    <set-property name="user.agent" value="gecko1_8" />

2. Use only one locale

By default, GWT use "default" locale and comment yours locales.

    <!-- GWT locale
    <extend-property name="locale" values="de_DE" />
    <extend-property name="locale" values="en_UK" />
    <extend-property name="locale" values="fr_FR" />
    <extend-property name="locale" values="hr_HR" />
    <extend-property name="locale" values="hu_HU" />
    <extend-property name="locale" values="it_IT" />
    <extend-property name="locale" values="pt_PT" />
    <extend-property name="locale" values="pl_PL" />
    <extend-property name="locale" values="nl_NL" />
     -->

With this two points, GWT really speeds up but i can improve this.

How to speed up the GWT compiler ? (Part III).

French version

Coming soon.

How to speed up the GWT compiler ? (Part I)

English version

I am working on an international CRM project based on JDK 6, GWT 1.5, MyGWT/Ext GWT, tomcat 6, maven, hibernate, spring, Oracle, ...

This business application must worked with Firefox 2, IE 6/7 and 9 locales (the target is about 15 locales).

This a very large GWT application and it takes a long time to compile, about 12 mn "only" for GWT maven module : this is a long time in development mode.

GWT spends time to compute permutations : create javascript file per browser/locale. With this kind of application, GWT produces 50 permutations :

  • 5 browsers : ie6, opera, gecko1_8, safari, gecko
  • 10 locales : default, de_DE, en_UK, fr_FR, hr_HR, hu_HU, it_IT, nl_NL, pl_PL, pt_PT

This is my module.gwt.xml :

<module>
    <!-- Inherit the core Web Toolkit stuff. -->
    <inherits name="com.google.gwt.user.User" />
    <inherits name="com.google.gwt.i18n.I18N" />

    <!-- Add support -->
    <inherits name="com.aaa.bbb.ccc.XXXCore" />
    <!-- Add mygwt support -->
    <inherits name="net.mygwt.ui.MyGWT" />
    <!-- Add hibernate4gwt support -->
    <inherits name="net.sf.hibernate4gwt.Hibernate4Gwt" />
    <inherits name="net.sf.hibernate4gwt.SqlDates"/>
    <!-- Add gwt-log support -->
    <inherits name="com.allen_sauer.gwt.log.gwt-log" />

    <!-- Add ftr-gwt-library-date -->
    <inherits name='org.cobogw.gwt.user.User' />
    <inherits name="eu.future.earth.gwt.FtrGwtLibrary" />

    <!-- GWT locale -->
    <extend-property name="locale" values="de_DE" />
    <extend-property name="locale" values="en_UK" />
    <extend-property name="locale" values="fr_FR" />
    <extend-property name="locale" values="hr_HR" />
    <extend-property name="locale" values="hu_HU" />
    <extend-property name="locale" values="it_IT" />
    <extend-property name="locale" values="pt_PT" />
    <extend-property name="locale" values="pl_PL" />
    <extend-property name="locale" values="nl_NL" />

    <!-- Logging -->
    <extend-property name="log_level" values="DEBUG,INFO,WARN,FATAL,EROR,OFF" />
    <set-property name="log_level" value="INFO" />

    <!-- Turn off "DivLogger" -->
    <set-property name="log_DivLogger" value="DISABLED" />

    <!-- Specify the app entry point class. -->
    <entry-point class="com.aaa.bbb.ccc.XXXEntryPoint" />

</module>

The main idea is to reduce permutations.

How to speed up the GWT compiler ? (Part II).

How to speed up the GWT compiler ? (Part III).

French version

Coming soon.

mercredi 6 février 2008

Patch GWT 1.5 / Hibernate4GWT

Pour utiliser Hibernate4GWT et GWT 1.5, il faut patcher Hibernate4GWT la partie "emul" sinon vous pouvez avoir ce genre de message à la compilation

[java] [ERROR] Line 22: The interface Comparable cannot be implemented more than once with different arguments: Comparable and Comparable<Date> 
[java] [ERROR] Line 86: Name clash: The method compareTo(Object) of type Date has the same erasure as compareTo(T) of type Comparable<T> 
but does not override it 

En fait, l'émulation JRE de Date et Timestamp ne compile plus avec un JDK 1.5. Voici les patches à passer sur Hibernate4GWT 1.3 :

Index: src/net/sf/hibernate4gwt/emul/java/sql/Timestamp.java
===================================================================
--- src/net/sf/hibernate4gwt/emul/java/sql/Timestamp.java       (revision 133)
+++ src/net/sf/hibernate4gwt/emul/java/sql/Timestamp.java       (working copy)
@@ -22,7 +22,7 @@
  * Emulation of the java.sql.TimeStamp class
  * Based on the source of java.util.Date emulation from GWT
  */
-public class Timestamp extends java.util.Date implements Cloneable, Comparable{
+public class Timestamp extends java.util.Date implements Cloneable {
   /**
    * Used only by toString().
    */
@@ -90,22 +90,6 @@
     return clone;
   }
 
-  public int compareTo(Timestamp other) {
-    long thisTime = getTime();
-    long otherTime = other.getTime();
-    if (thisTime < otherTime) {
-      return -1;
-    } else if (thisTime > otherTime) {
-      return 1;
-    } else {
-      return getNanos() - other.getNanos();
-    }
-  }
-
-  public int compareTo(Object other) {
-    return compareTo((Timestamp) other);
-  }
-
   /**
    *  Return the names for the days of the week as specified by the Date
    *  specification.
@@ -269,4 +253,4 @@
     this.jsdate = new Date(date);
     this.nanos = 0;
   }-*/;
-}
\ No newline at end of file
+}
Index: src/net/sf/hibernate4gwt/emul/java/sql/Date.java
===================================================================
--- src/net/sf/hibernate4gwt/emul/java/sql/Date.java    (revision 133)
+++ src/net/sf/hibernate4gwt/emul/java/sql/Date.java    (working copy)
@@ -19,7 +19,7 @@
  * Emulation of the java.sql.Date
  * Based on the source of java.util.Date emulation from GWT
  */
-public class Date extends java.util.Date implements Cloneable, Comparable {
+public class Date extends java.util.Date implements Cloneable {
   /**
    * Used only by toString().
    */
@@ -71,22 +71,6 @@
     return new Date(getTime());
   }
 
-  public int compareTo(Date other) {
-    long thisTime = getTime();
-    long otherTime = other.getTime();
-    if (thisTime < otherTime) {
-      return -1;
-    } else if (thisTime > otherTime) {
-      return 1;
-    } else {
-      return 0;
-    }
-  }
-
-  public int compareTo(Object other) {
-    return compareTo((Date) other);
-  }
-
   /**
    *  Return the names for the days of the week as specified by the Date
    *  specification.
Index: build.xml
===================================================================
--- build.xml   (revision 133)
+++ build.xml   (working copy)
@@ -3,7 +3,7 @@
 
        <!-- Properties -->
     <property environment="env"/>
-    <property name="version" value="1.0.3"/>
+    <property name="version" value="1.0.3-r133-patch"/>
        <property name="project" value="hibernate4gwt" />
        <property name="output.jar" value="${project}-${version}.jar" />

- page 1 de 2