Integrate Elemental to the build and deploy as Maven artifact
Contributed by tbroyer

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


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11064 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/build.xml b/build.xml
index 3e9f299..37d6f9c 100755
--- a/build.xml
+++ b/build.xml
@@ -66,6 +66,11 @@
     <gwt.ant dir="user" />
   </target>
 
+  <target name="elemental" description="[subdir] Builds (or runs ${target} if set) only the elemental library">
+    <call-subproject subproject="user" subtarget="build"/>
+    <gwt.ant dir="elemental" />
+  </target>
+
   <target name="soyc" description="[subdir] Builds (or runs ${target} if set) only the soyc library">
     <call-subproject subproject="dev" subtarget="build"/>
     <call-subproject subproject="user" subtarget="build"/>
diff --git a/common.ant.xml b/common.ant.xml
index 166568e..e39e052 100755
--- a/common.ant.xml
+++ b/common.ant.xml
@@ -152,7 +152,7 @@
   </presetdef>
 
   <presetdef name="gwt.javac">
-    <javac srcdir="src" destdir="${javac.out}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.source}" target="${javac.target}" nowarn="${javac.nowarn}" encoding="${javac.encoding}" fork="true" memoryMaximumSize="1024m" />
+    <javac srcdir="src" destdir="${javac.out}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.source}" target="${javac.target}" nowarn="${javac.nowarn}" encoding="${javac.encoding}" fork="true" memoryMaximumSize="1024m" includeantruntime="false" />
   </presetdef>
 
   <macrodef name="gwt.jar">
diff --git a/distro-source/build.xml b/distro-source/build.xml
index 791aef6..64e8e33 100755
--- a/distro-source/build.xml
+++ b/distro-source/build.xml
@@ -17,6 +17,14 @@
     <!-- TODO: figure out how to share most of this across platforms -->
     <mkdir dir="${gwt.build.dist}" />
     <mkdir dir="${gwt.build.out}/samples-scripts"/>
+    <if>
+      <not>
+        <available file="${gwt.build.lib}/gwt-elemental.jar" type="file" />
+      </not>
+      <then>
+        <echo message="Building SDK without Elemental - did you forget to call 'ant elemental' before 'ant dist'?" />
+      </then>
+    </if>
     <zip destfile="${project.dist}">
       <!-- jars -->
       <zipfileset file="${gwt.build.lib}/gwt-dev.jar" prefix="${project.distname}" />
@@ -28,6 +36,7 @@
       <zipfileset file="${gwt.build.lib}/gwt-soyc-vis.jar" prefix="${project.distname}" />
       <zipfileset file="${gwt.build.lib}/gwt-api-checker.jar" prefix="${project.distname}" />
       <zipfileset file="${gwt.build.lib}/requestfactory*.jar" prefix="${project.distname}" />
+      <zipfileset file="${gwt.build.lib}/gwt-elemental.jar" prefix="${project.distname}" />
       <!-- jni libs-->
       <zipfileset dir="${gwt.build.jni}/windows" prefix="${project.distname}" />
 
diff --git a/elemental/build.xml b/elemental/build.xml
index fe48c91..d30ec28 100644
--- a/elemental/build.xml
+++ b/elemental/build.xml
@@ -16,7 +16,7 @@
 
   <target name="compile" description="Compile all class files">
     <mkdir dir="${javac.out}" />
-    <gwt.javac excludes="**/super/**">
+    <gwt.javac srcdir="src:idl/generated/src" excludes="**/super/**">
       <classpath>
         <pathelement location="${gwt.dev.jar}" />
         <pathelement location="${gwt.user.jar}" />
@@ -41,6 +41,7 @@
           <java classname="com.google.gwt.dev.CompileModule" fork="yes" failonerror="true">
             <classpath>
               <pathelement location="${gwt.root}/elemental/src" />
+              <pathelement location="${gwt.root}/elemental/idl/generated/src" />
               <pathelement location="${gwt.dev.jar}" />
               <pathelement location="${gwt.user.jar}" />
             </classpath>
@@ -56,6 +57,8 @@
 
   <target name="clean"
       description="Cleans this project's intermediate and output files">
+    <delete dir="idl/generated" />
+    <delete dir="idl/database" />
     <delete dir="${project.build}" />
     <delete file="${project.lib}" />
   </target>
diff --git a/elemental/idl/build b/elemental/idl/build
index 8f6b266..028ea83 100755
--- a/elemental/idl/build
+++ b/elemental/idl/build
@@ -10,4 +10,7 @@
 
 python ${ROOT}/scripts/elemental_fremontcutbuilder.py
 python ${ROOT}/scripts/elementaldomgenerator.py
-cp -R ${ROOT}/generated/src/elemental/* ${ROOT}/../java/elemental/
+# Keep compatibility with Google's internal build
+if [ -d ${ROOT}/../java/elemental/ ]; then
+  cp -R ${ROOT}/generated/src/elemental/* ${ROOT}/../java/elemental/
+fi
diff --git a/elemental/idl/scripts/idlparser.py b/elemental/idl/scripts/idlparser.py
index fcf7e60..ba67687 100755
--- a/elemental/idl/scripts/idlparser.py
+++ b/elemental/idl/scripts/idlparser.py
@@ -412,8 +412,7 @@
       includePaths -- an array of path strings.
     """
     # FIXME: Handle gcc not found, or any other processing errors
-    if 'CC' in os.environ:
-      gcc = os.environ['CC']
+    gcc = os.environ.get('CC', None)
     if not gcc:
       gcc = 'gcc'
     cmd = [gcc, '-E', '-P', '-C', '-x', 'c++'];
diff --git a/maven/lib-gwt.sh b/maven/lib-gwt.sh
index cdccbb3..af8436c 100644
--- a/maven/lib-gwt.sh
+++ b/maven/lib-gwt.sh
@@ -97,7 +97,13 @@
   echo "Removing org.json classes from gwt-dev"
   zip -d $GWT_EXTRACT_DIR/gwt-dev.jar org/json/*
 
-  for i in dev user servlet codeserver
+  # Silently skip Elemental if it doesn't exist
+  gwtLibs='dev user servlet codeserver'
+  if [ -f $GWT_EXTRACT_DIR/gwt-elemental.jar ]; then
+    gwtLibs="${gwtLibs} elemental"
+  fi
+
+  for i in $gwtLibs
   do
     CUR_FILE=`ls $GWT_EXTRACT_DIR/gwt-${i}.jar`
     
@@ -126,7 +132,7 @@
   # push parent poms
   maven-deploy-file $mavenRepoUrl $mavenRepoId $pomDir/gwt/pom.xml $pomDir/gwt/pom.xml
 
-  for i in dev user servlet codeserver
+  for i in $gwtLibs
   do
     CUR_FILE=`ls $GWT_EXTRACT_DIR/gwt-${i}.jar`
     gwtPomFile=$pomDir/gwt/gwt-$i/pom.xml
diff --git a/maven/poms/gwt/gwt-elemental/pom-template.xml b/maven/poms/gwt/gwt-elemental/pom-template.xml
new file mode 100644
index 0000000..cf94ed3
--- /dev/null
+++ b/maven/poms/gwt/gwt-elemental/pom-template.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.google.gwt</groupId>
+        <artifactId>gwt</artifactId>
+        <version>${gwtVersion}</version>
+    </parent>
+    <groupId>com.google.gwt</groupId>
+    <artifactId>gwt-elemental</artifactId>
+    <packaging>jar</packaging>
+    <version>${gwtVersion}</version>
+
+    <dependencies>
+      <dependency>
+        <groupId>com.google.gwt</groupId>
+        <artifactId>gwt-user</artifactId>
+        <version>${gwtVersion}</version>
+      </dependency>
+    </dependencies>
+</project>
diff --git a/samples/build.xml b/samples/build.xml
index 29c0327..0fe5f5f 100644
--- a/samples/build.xml
+++ b/samples/build.xml
@@ -73,7 +73,7 @@
     <length property="gwt.sample.length">
       <fileset dir="${gwt.build.out}/samples" includes="*/war/*/*.cache.html,*/war/*/*.cache.js"/>
     </length>
-    <echo message="compiled size of all samples is ${gwt.sample.length} bytes."/>
+    <echo message="compiled size of all samples is ${gwt.sample.length} bytes." level="info"/>
   </target>
 
   <target name="checkstyle" description="Static analysis of GWT source">
diff --git a/tools/cldr-import/build.xml b/tools/cldr-import/build.xml
index 8de567e..685ff75 100644
--- a/tools/cldr-import/build.xml
+++ b/tools/cldr-import/build.xml
@@ -37,7 +37,8 @@
     <javac srcdir="src" destdir="${javac.out}"
         debug="${javac.debug}" debuglevel="${javac.debuglevel}"
         source="${javac.source}" target="${javac.target}"
-        nowarn="${javac.nowarn}" encoding="${javac.encoding}">
+        nowarn="${javac.nowarn}" encoding="${javac.encoding}"
+        includeantruntime="false">
       <classpath refid="project.class.path"/>
     </javac>
     <copy todir="${javac.out}">