CompileModule creates a serialized set of compilation units to represent
a GWT module as a <module>.gwt file.  This is intended to be run when building
a library to support incremental compilation of a module.

Review at http://gwt-code-reviews.appspot.com/1448808


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10304 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/build.xml b/user/build.xml
index bb1d8dd..579e7a6 100755
--- a/user/build.xml
+++ b/user/build.xml
@@ -141,7 +141,65 @@
     </gwt.javac>
   </target>
 
-  <target name="build" depends="compile"
+  <!-- Precompile some GWT modules to speed up end-user builds   -->
+  <!-- TODO(zundel): Find a way to precompile  all modules       -->
+  <!--               without tedious manual specification        -->
+  <target name="precompile.modules" depends="compile">
+    <outofdate>
+      <sourcefiles>
+        <fileset dir="${gwt.root}/user/src" />
+        <fileset dir="${gwt.root}/user/super" />
+        <fileset dir="${gwt.root}/dev/core/src" />
+        <fileset dir="${gwt.root}/dev/core/super" />
+        <fileset file="${gwt.dev.jar}" />
+      </sourcefiles>
+      <targetfiles>
+        <!-- TODO(zundel): this is a mechanical transform        -->
+        <!-- from module name.  There must be a better way.      -->
+        <pathelement location="${project.build}/bin/com/google/gwt/core/Core.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/json/JSON.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/regexp/RegExp.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/user/User.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/xml/XML.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/rpc/RPC.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/debug/Debug.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/place/Place.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/activity/Activity.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/web/bindery/event/Event.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/web/bindery/autobean/AutoBean.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/web/bindery/requestfactory/RequestFactory.gwtar" />
+        <pathelement location="${project.build}/bin/com/google/gwt/logging/Logging.gwtar" />
+      </targetfiles>
+      <sequential>
+        <compileModule>
+          <module>
+            <!-- Order is important!  Modules that inherit from  -->
+            <!-- others should come later in the list.           -->
+            <!-- All modules depend on Core                      -->
+            <arg value="com.google.gwt.core.Core" />
+            <arg value="com.google.gwt.json.JSON" />
+            <arg value="com.google.gwt.regexp.RegExp" />
+            <arg value="com.google.gwt.user.User" />
+    
+            <!-- Below are modules that depend on User           -->
+            <arg value="com.google.gwt.xml.XML" />
+            <arg value="com.google.gwt.rpc.RPC" />
+            <arg value="com.google.gwt.debug.Debug" />
+            <arg value="com.google.gwt.logging.Logging" />
+    
+            <arg value="com.google.gwt.place.Place" />
+            <arg value="com.google.gwt.activity.Activity" />
+    
+            <arg value="com.google.web.bindery.event.Event" />
+            <arg value="com.google.web.bindery.autobean.AutoBean" />
+            <arg value="com.google.web.bindery.requestfactory.RequestFactory" />
+          </module>
+        </compileModule>
+      </sequential>
+    </outofdate>
+  </target>
+
+  <target name="build" depends="precompile.modules"
       description="Build and package this project">
     <mkdir dir="${gwt.build.lib}" />
     <gwt.jar>
@@ -704,6 +762,31 @@
       </sequential>
     </macrodef>
 
+    <macrodef name="compileModule">
+      <element name="module" />
+      <sequential>
+        <gwt.timer name="Pre-compile module">
+          <java classname="com.google.gwt.dev.CompileModule" fork="yes" failonerror="true">
+            <classpath>
+              <pathelement location="${gwt.root}/user/src" />
+              <pathelement location="${gwt.root}/user/super" />
+              <pathelement location="${gwt.root}/dev/core/src" />
+              <pathelement location="${gwt.root}/dev/core/super" />
+              <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar" />
+              <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA-sources.jar" />
+              <pathelement location="${gwt.root}/build/out/user/bin" />
+              <pathelement location="${gwt.dev.jar}" />
+            </classpath>
+            <jvmarg value="-Xmx512M" />
+            <module />
+            <arg value="-strict" />
+            <arg value="-out" />
+            <arg value="${project.build}/bin" />
+          </java>
+        </gwt.timer>
+      </sequential>
+    </macrodef>
+
     <target name="tck.report">
       <mkdir dir="${junit.out}/tck-report" />
       <mkdir dir="${junit.out}/tck-report/text" />
diff --git a/user/src/com/google/gwt/activity/Activity.gwt.xml b/user/src/com/google/gwt/activity/Activity.gwt.xml
index 78b19d0..dbdd296 100644
--- a/user/src/com/google/gwt/activity/Activity.gwt.xml
+++ b/user/src/com/google/gwt/activity/Activity.gwt.xml
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 0.0.999//EN" "http://google-web-toolkit.googlecode.com/svn/tags/0.0.999/distro-source/core/src/gwt-module.dtd">
 <module>
-  <inherits name='com.google.gwt.user.User'/>
   <inherits name='com.google.gwt.place.Place'/>
 
   <source path="shared"/>
diff --git a/user/src/com/google/gwt/debug/Debug.gwt.xml b/user/src/com/google/gwt/debug/Debug.gwt.xml
index 338588a..9d77e6d 100644
--- a/user/src/com/google/gwt/debug/Debug.gwt.xml
+++ b/user/src/com/google/gwt/debug/Debug.gwt.xml
@@ -14,6 +14,8 @@
 
 <!-- Adds debug ID support for UIObjects.                                   -->
 <module>
+  <inherits name="com.google.gwt.core.Core" />
+  
   <!-- Enable or disable the UIObject.ensureDebugID method -->
   <define-property name="gwt.enableDebugId" values="true, false"/>
   
diff --git a/user/src/com/google/gwt/i18n/CldrLocales.gwt.xml b/user/src/com/google/gwt/i18n/CldrLocales.gwt.xml
index 6c80f23..9a109da 100644
--- a/user/src/com/google/gwt/i18n/CldrLocales.gwt.xml
+++ b/user/src/com/google/gwt/i18n/CldrLocales.gwt.xml
@@ -14,6 +14,8 @@
 
 <!-- List of all locales imported into GWT from CLDR, as runtime locales -->
 <module>
+  <inherits name="com.google.gwt.user.User"/>
+  <inherits name="com.google.gwt.i18n.I18N"/>
   <extend-configuration-property name="runtime.locales" value="aa"/>
   <extend-configuration-property name="runtime.locales" value="aa_DJ"/>
   <extend-configuration-property name="runtime.locales" value="aa_ER"/>
diff --git a/user/src/com/google/gwt/i18n/I18N.gwt.xml b/user/src/com/google/gwt/i18n/I18N.gwt.xml
index 6473a34..15f35ab 100644
--- a/user/src/com/google/gwt/i18n/I18N.gwt.xml
+++ b/user/src/com/google/gwt/i18n/I18N.gwt.xml
@@ -15,6 +15,7 @@
 <!-- Internationalization support.                                          -->
 <!--                                                                        -->
 <module>
+  <inherits name="com.google.gwt.core.Core" />
   <inherits name="com.google.gwt.regexp.RegExp"/>
   <inherits name="com.google.gwt.safehtml.SafeHtml"/>
   <source path="" includes="client/,shared/" />
diff --git a/user/src/com/google/gwt/logging/Logging.gwt.xml b/user/src/com/google/gwt/logging/Logging.gwt.xml
index 4646c37..6989f1b 100644
--- a/user/src/com/google/gwt/logging/Logging.gwt.xml
+++ b/user/src/com/google/gwt/logging/Logging.gwt.xml
@@ -13,7 +13,8 @@
 <!-- limitations under the License.                                         -->
 
 <module>
-  <inherits name='com.google.gwt.json.JSON'/>
+  <inherits name="com.google.gwt.json.JSON"/>
+  <inherits name="com.google.gwt.user.User" />
   <inherits name="com.google.gwt.logging.LogImpl"/>
   <source path="client" />
   <source path="shared" />
diff --git a/user/src/com/google/gwt/regexp/RegExp.gwt.xml b/user/src/com/google/gwt/regexp/RegExp.gwt.xml
index 285dd66..146103c 100644
--- a/user/src/com/google/gwt/regexp/RegExp.gwt.xml
+++ b/user/src/com/google/gwt/regexp/RegExp.gwt.xml
@@ -14,6 +14,7 @@
 
 <!-- regular expressions support.                                           -->
 <module>
+  <inherits name="com.google.gwt.core.Core" />
   <source path="shared" />
   <super-source path="super" />
 </module>
diff --git a/user/src/com/google/gwt/storage/Storage.gwt.xml b/user/src/com/google/gwt/storage/Storage.gwt.xml
index 98c0055..48c79de 100644
--- a/user/src/com/google/gwt/storage/Storage.gwt.xml
+++ b/user/src/com/google/gwt/storage/Storage.gwt.xml
@@ -13,8 +13,7 @@
 <!-- limitations under the License.                                         -->
 
 <module>
-  <inherits name="com.google.gwt.core.Core" />
-  <inherits name="com.google.gwt.user.UserAgent" />
+  <inherits name="com.google.gwt.user.User" />
 
   <!-- Define the storage support property -->
   <define-property name="storageSupport" values="maybe,no" />
diff --git a/user/src/com/google/gwt/view/View.gwt.xml b/user/src/com/google/gwt/view/View.gwt.xml
index 06676be..21babcb 100644
--- a/user/src/com/google/gwt/view/View.gwt.xml
+++ b/user/src/com/google/gwt/view/View.gwt.xml
@@ -14,6 +14,6 @@
   the License.
 -->
 <module>
-   <inherits name="com.google.gwt.core.Core"/>
+   <inherits name="com.google.gwt.user.User"/>
    <source path="client"/>
 </module>
diff --git a/user/src/com/google/gwt/xml/XML.gwt.xml b/user/src/com/google/gwt/xml/XML.gwt.xml
index 4eaf0d1..3c75c56 100644
--- a/user/src/com/google/gwt/xml/XML.gwt.xml
+++ b/user/src/com/google/gwt/xml/XML.gwt.xml
@@ -15,9 +15,8 @@
 <!-- XML parsing support.                                                   -->
 <!--                                                                        -->
 <module>
-  <inherits name="com.google.gwt.core.Core"/>
-  <inherits name="com.google.gwt.user.UserAgent"/>
-
+  <inherits name="com.google.gwt.user.User"/>
+  
   <!-- Fall through to this rule for all other browsers -->
   <replace-with class="com.google.gwt.xml.client.impl.XMLParserImplStandard">
     <when-type-is class="com.google.gwt.xml.client.impl.XMLParserImpl"/>
diff --git a/user/src/com/google/web/bindery/autobean/AutoBean.gwt.xml b/user/src/com/google/web/bindery/autobean/AutoBean.gwt.xml
index 88b8981..fc7fbd8 100644
--- a/user/src/com/google/web/bindery/autobean/AutoBean.gwt.xml
+++ b/user/src/com/google/web/bindery/autobean/AutoBean.gwt.xml
@@ -13,7 +13,6 @@
 
 <!-- AutoBean framework -->
 <module>
-  <inherits name="com.google.gwt.core.Core" />
   <inherits name="com.google.gwt.user.User" />
   <source path="gwt/client" />
   <source path="shared" />
diff --git a/user/src/com/google/web/bindery/event/Event.gwt.xml b/user/src/com/google/web/bindery/event/Event.gwt.xml
index 8bafd18..bd600e6 100644
--- a/user/src/com/google/web/bindery/event/Event.gwt.xml
+++ b/user/src/com/google/web/bindery/event/Event.gwt.xml
@@ -14,5 +14,7 @@
   the License.
 -->
 <module>
+  <inherits name="com.google.gwt.core.Core" />
+  
   <source path="shared" />
 </module>