Refactored buildsystem for consistency and generality.


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@33 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/build.xml b/build.xml
index 212e632..fc48e3b 100755
--- a/build.xml
+++ b/build.xml
@@ -1,30 +1,48 @@
-<project name="GWT" default="all" basedir=".">

+<project name="GWT" default="build" basedir=".">

 	<property name="gwt.root" location="." />

-	<property name="project.tail" value="" />
+	<property name="project.tail" value="" />

 	<import file="${gwt.root}/common.ant.xml" />

 

-	<target name="dev" description="Builds dev">

-		<ant dir="dev" inheritall="false"/>

+	<!-- "build" is the default when subprojects are directly targetted -->

+	<property name="target" value="build" />

+

+	<target name="dist" depends="dev, user, servlet, jni" description="Run the distributions">

+		<ant dir="distro-source" inheritall="false" target="${target}" />

 	</target>

 

-	<target name="user" depends="dev" description="Builds user">

-		<ant dir="user" inheritall="false"/>

+	<target name="dev" description="Run dev">

+		<ant dir="dev" inheritall="false" target="${target}" />

 	</target>

+

+	<target name="user" depends="dev" description="Run user">

+		<ant dir="user" inheritall="false" target="${target}" />

+	</target>

+

+	<target name="servlet" depends="user" description="Run servlet">

+		<ant dir="servlet" inheritall="false" target="${target}" />

+	</target>

+

+	<target name="jni" description="Run jni">

+		<ant dir="jni" inheritall="false" target="${target}" />

+	</target>

+

+	<target name="-do" depends="dist" description="Run all subprojects"/>

 	

-	<target name="servlet" depends="user" description="Builds servlet">

-		<ant dir="servlet" inheritall="false"/>

+	<target name="build" description="Builds GWT">

+		<antcall target="-do">

+			<param name="target" value="build" />

+		</antcall>

 	</target>

 

-	<target name="jni" description="Builds jni">

-		<ant dir="jni" inheritall="false"/>

+	<target name="checkstyle" description="Static analysis of GWT source">

+		<antcall target="-do">

+			<param name="target" value="checkstyle" />

+		</antcall>

 	</target>

 

-	<target name="clean" description="Cleans all GWT build outputs">

-		<delete dir="${gwt.build}" failonerror="false" />

+	<target name="test" depends="build" description="Test GWT">

+		<antcall target="-do">

+			<param name="target" value="test" />

+		</antcall>

 	</target>

-

-	<target name="build" depends="dev, user, servlet, jni" description="Builds GWT" />

-

-	<target name="all" depends="build" description="Builds GWT" />

-

 </project>

diff --git a/common.ant.xml b/common.ant.xml
index 84c1798..b4a5dfb 100755
--- a/common.ant.xml
+++ b/common.ant.xml
@@ -94,6 +94,7 @@
 	<presetdef name="gwt.checkstyle">

 		<checkstyle config="${gwt.root}/eclipse/settings/code-style/gwtCheckStyle.xml" maxWarnings="0">

 			<fileset dir="src" />

+			<property key="checkstyle.header.file" file="${gwt.root}/eclipse/settings/code-style/google.header" />

 

 			<!-- Location of cache-file if we decide to try turning it on -->

 			<!--

@@ -101,4 +102,17 @@
 			-->

 		</checkstyle>

 	</presetdef>

+

+	<!-- Default implementations of the required targets; projects should

+	override the ones that matter -->

+	<target name="all" depends="verify" />

+	<target name="verify" depends="checkstyle, test" description="Verify this project" />

+	<target name="checkstyle" description="Static analysis of source" />

+	<target name="test" depends="build" description="Test this project" />

+	<target name="build" description="Build and (maybe) package this project" />

+

+	<target name="clean" description="Cleans this project's intermediate and output files">

+		<delete dir="${project.build}" />

+	</target>

+

 </project>

diff --git a/dev/build.xml b/dev/build.xml
index b00d229..7493c64 100755
--- a/dev/build.xml
+++ b/dev/build.xml
@@ -1,23 +1,7 @@
-<project name="dev" default="all" basedir=".">

+<project name="dev" default="build" basedir=".">

 	<property name="gwt.root" location=".." />

-	<property name="project.tail" value="dev" />
-	<import file="${gwt.root}/common.ant.xml" />

-

-	<target name="core" description="Builds dev/core">

-		<ant dir="core" inheritall="false"/>

-	</target>

-

-	<target name="linux" depends="core" description="Builds dev/linux">

-		<ant dir="linux" inheritall="false"/>

-	</target>

-	

-	<target name="windows" depends="core" description="Builds dev/linux">

-		<ant dir="windows" inheritall="false"/>

-	</target>

-

-	<target name="mac" depends="core" description="Builds dev/linux">

-		<ant dir="mac" inheritall="false"/>

-	</target>

+	<property name="project.tail" value="dev" />

+	<import file="${gwt.root}/platforms.ant.xml" />

 

 	<target name="clean" description="Cleans this project's intermediate and output files">

 		<delete dir="${project.build}" failonerror="false" />

@@ -25,7 +9,4 @@
 			<fileset dir="${gwt.build.lib}"  includes="gwt-dev-*.jar"/>

 		</delete>

 	</target>

-

-	<target name="all" depends="linux,windows,mac" description="Builds all platforms" />

-

 </project>

diff --git a/dev/core/build.xml b/dev/core/build.xml
index ba0cdbd..6e13110 100755
--- a/dev/core/build.xml
+++ b/dev/core/build.xml
@@ -1,6 +1,6 @@
-<project name="dev-core" default="all" basedir=".">

+<project name="dev-core" default="build" basedir=".">

 	<property name="gwt.root" location="../.." />

-	<property name="project.tail" value="dev/core" />
+	<property name="project.tail" value="dev/core" />

 	<import file="${gwt.root}/common.ant.xml" />

 

 	<target name="unjar.deps" description="Unzips all dependency jars into the output folder">

@@ -57,9 +57,9 @@
 				<pathelement location="${gwt.tools.lib}/eclipse/org.eclipse.swt.gtk-linux-3.2.1.jar" />

 			</classpath>

 		</gwt.javac>

-	</target>
+	</target>

 

-	<target name="verify" description="Static analysis of source">

+	<target name="checkstyle" description="Static analysis of source">

 		<gwt.checkstyle>

 			<fileset dir="super/com/google/gwt/dev/jjs/intrinsic"/>

 		</gwt.checkstyle>

@@ -69,7 +69,4 @@
 		<delete dir="${project.build}" />

 		<delete file="${project.lib}" />

 	</target>

-

-	<target name="all" depends="build" description="Builds this project" />

-

 </project>

diff --git a/dev/linux/build.xml b/dev/linux/build.xml
index f14e19a..6d68ba7 100755
--- a/dev/linux/build.xml
+++ b/dev/linux/build.xml
@@ -1,4 +1,4 @@
-<project name="dev-linux" default="all" basedir=".">

+<project name="dev-linux" default="build" basedir=".">

 	<property name="project.tail" value="dev/linux" />

 	<property name="gwt.dev.swt.jar" value="org.eclipse.swt.gtk-linux-3.2.1.jar"/>

 	<import file="../common.ant.xml" />

diff --git a/dev/mac/build.xml b/dev/mac/build.xml
index 6953728..20e2930 100755
--- a/dev/mac/build.xml
+++ b/dev/mac/build.xml
@@ -1,4 +1,4 @@
-<project name="dev-mac" default="all" basedir=".">

+<project name="dev-mac" default="build" basedir=".">

 	<property name="project.tail" value="dev/mac" />

 	<property name="gwt.dev.swt.jar" value="org.eclipse.swt.carbon-macosx-3.2.1.jar"/>

 	<import file="../common.ant.xml" />

diff --git a/dev/windows/build.xml b/dev/windows/build.xml
index 2fb7a12..d33f9c3 100755
--- a/dev/windows/build.xml
+++ b/dev/windows/build.xml
@@ -1,4 +1,4 @@
-<project name="dev-windows" default="all" basedir=".">
+<project name="dev-windows" default="build" basedir=".">
 	<property name="project.tail" value="dev/windows" />
 	<property name="gwt.dev.swt.jar" value="org.eclipse.swt.win32-win32-3.2.1.jar"/>
 	<import file="../common.ant.xml" />
diff --git a/distro-source/build.xml b/distro-source/build.xml
index c4abc9e..bfc6d13 100755
--- a/distro-source/build.xml
+++ b/distro-source/build.xml
@@ -1,25 +1,10 @@
-<project name="dist" default="all" basedir=".">

+<project name="dist" default="build" basedir=".">

 	<property name="gwt.root" location=".." />

-	<property name="project.tail" value="distro-source" />
-	<import file="${gwt.root}/common.ant.xml" />

-

-	<target name="linux" description="Builds dist/linux">

-		<ant dir="linux" inheritall="false"/>

-	</target>

-	

-	<target name="windows" description="Builds dist/linux">

-		<ant dir="windows" inheritall="false"/>

-	</target>

-

-	<target name="mac" description="Builds dist/linux">

-		<ant dir="mac" inheritall="false"/>

-	</target>

+	<property name="project.tail" value="distro-source" />

+	<import file="${gwt.root}/platforms.ant.xml" />

 

 	<target name="clean" description="Cleans this project's intermediate and output files">

 		<delete dir="${gwt.build.dist}" failonerror="false" />

 		<delete dir="${gwt.build.staging}" failonerror="false" />

 	</target>

-

-	<target name="all" depends="linux,windows,mac" description="Builds all platforms" />

-

 </project>

diff --git a/distro-source/common.ant.xml b/distro-source/common.ant.xml
index 187b0b6..033e2ee 100755
--- a/distro-source/common.ant.xml
+++ b/distro-source/common.ant.xml
@@ -6,7 +6,7 @@
 	<property name="project.distname" value="gwt-${dist.platform}-${gwt.version}" />

 	<property name="project.staging" location="${gwt.build.staging}/${project.distname}" />

 

-	<target name="build" description="Copies items into the staging area">

+	<target name="stage" description="Copies items into the staging area">

 		<mkdir dir="${project.staging}" />

 

 		<copy todir="${project.staging}">

@@ -18,7 +18,7 @@
 			<fileset dir="../core/src" />

 			<fileset dir="src" />

 		</copy>

-        <antcall target="build.platform" />

+        <antcall target="stage.platform" />

 		<chmod perm="a+r">

 			<dirset dir="${project.staging}" />

 			<fileset dir="${project.staging}" />

diff --git a/distro-source/linux/build.xml b/distro-source/linux/build.xml
index 1d5c37e..62523d7 100755
--- a/distro-source/linux/build.xml
+++ b/distro-source/linux/build.xml
@@ -1,9 +1,9 @@
-<project name="dist-linux" default="all" basedir=".">

+<project name="dist-linux" default="build" basedir=".">

 	<property name="dist.platform" value="linux" />

 	<import file="../common.ant.xml" />

 	<property name="project.dist" location="${gwt.build.dist}/${project.distname}.tar.gz" />

 

-	<target name="build.platform" description="Copies platform-specific items into the staging area">

+	<target name="stage.platform" description="Copies platform-specific items into the staging area">

 		<gwt.untar src="${gwt.tools.redist}/mozilla/mozilla-1.7.12.tar.gz" dest="${project.staging}" />

 		<copy todir="${project.staging}">

 			<fileset dir="${gwt.tools.lib}/eclipse">

@@ -12,7 +12,7 @@
 		</copy>

 	</target>

 

-	<target name="package" depends="build" description="Packages the distro staging area">

+	<target name="build" depends="stage" description="Packages the distro staging area">

 		<mkdir dir="${gwt.build.dist}" />

 		<!-- GNU tar handles permissions and symlinks correctly -->

 		<exec executable="tar" failonerror="true">

@@ -23,6 +23,4 @@
 			<arg value="${project.distname}" />

 		</exec>

 	</target>

-

-	<target name="all" depends="package" description="Builds and packages this project" />

 </project>

diff --git a/distro-source/mac/build.xml b/distro-source/mac/build.xml
index 2e707b0..07e8b96 100755
--- a/distro-source/mac/build.xml
+++ b/distro-source/mac/build.xml
@@ -1,9 +1,9 @@
-<project name="dist-mac" default="all" basedir=".">

+<project name="dist-mac" default="build" basedir=".">

 	<property name="dist.platform" value="mac" />

 	<import file="../common.ant.xml" />

 	<property name="project.dist" location="${gwt.build.dist}/${project.distname}.tar.gz" />

 

-	<target name="build.platform" description="Copies platform-specific items into the staging area">

+	<target name="stage.platform" description="Copies platform-specific items into the staging area">

 		<gwt.untar src="${gwt.tools.redist}/webkit/WebKit-418.9.tar.gz" dest="${project.staging}" />

 		<copy todir="${project.staging}">

 			<fileset dir="${gwt.tools.lib}/eclipse">

@@ -14,7 +14,7 @@
 		</copy>

 	</target>

 

-	<target name="package" depends="build" description="Packages the distro staging area">

+	<target name="build" depends="stage" description="Packages the distro staging area">

 		<mkdir dir="${gwt.build.dist}" />

 		<!-- GNU tar handles permissions and symlinks correctly -->

 		<exec executable="tar" failonerror="true">

@@ -25,6 +25,4 @@
 			<arg value="${project.distname}" />

 		</exec>

 	</target>

-

-	<target name="all" depends="package" description="Builds and packages this project" />

 </project>

diff --git a/distro-source/windows/build.xml b/distro-source/windows/build.xml
index 378fc86..9e2843e 100755
--- a/distro-source/windows/build.xml
+++ b/distro-source/windows/build.xml
@@ -1,9 +1,9 @@
-<project name="dist-windows" default="all" basedir=".">

+<project name="dist-windows" default="build" basedir=".">

 	<property name="dist.platform" value="windows" />

 	<import file="../common.ant.xml" />

 	<property name="project.dist" location="${gwt.build.dist}/${project.distname}.zip" />

 

-	<target name="build.platform" description="Copies platform-specific items into the staging area">

+	<target name="stage.platform" description="Copies platform-specific items into the staging area">

 		<copy todir="${project.staging}">

 			<fileset dir="${gwt.tools.lib}/eclipse">

 				<include name="swt-*win32-3235.dll" />

@@ -11,14 +11,12 @@
 		</copy>

 	</target>

 

-	<target name="package" depends="build" description="Packages the distro staging area">

+	<target name="build" depends="stage" description="Packages the distro staging area">

 		<mkdir dir="${gwt.build.dist}" />

 		<zip destfile="${project.dist}">

 			<fileset dir="${gwt.build.staging}">

-				<include name="${project.distname}/**"/>

+				<include name="${project.distname}/**" />

 			</fileset>

 		</zip>

 	</target>

-

-	<target name="all" depends="package" description="Builds and packages this project" />

 </project>

diff --git a/eclipse/settings/code-style/gwtCheckStyle.xml b/eclipse/settings/code-style/gwtCheckStyle.xml
index b1288d7..b721072 100644
--- a/eclipse/settings/code-style/gwtCheckStyle.xml
+++ b/eclipse/settings/code-style/gwtCheckStyle.xml
@@ -58,7 +58,7 @@
             <property name="tokens" value="METHOD_DEF"/>

         </module>

         <module name="Header">

-            <property name="headerFile" value="C:\src-gwt\eclipse\settings\code-style\google.header"/>

+            <property name="headerFile" value="${checkstyle.header.file}"/>

         </module>

         <module name="ImportOrder">

             <property name="groups" value="com.google, com,  junit, net,org, java,javax"/>

diff --git a/jni/build.xml b/jni/build.xml
index c7724c7..443c659 100755
--- a/jni/build.xml
+++ b/jni/build.xml
@@ -1,24 +1,5 @@
-<project name="jni" default="all" basedir=".">

+<project name="jni" default="build" basedir=".">

 	<property name="gwt.root" location=".." />

-	<property name="project.tail" value="jni" />
-	<import file="${gwt.root}/common.ant.xml" />

-

-	<target name="linux" description="Builds jni/linux">

-		<ant dir="linux" inheritall="false"/>

-	</target>

-	

-	<target name="windows" description="Builds jni/linux">

-		<ant dir="windows" inheritall="false"/>

-	</target>

-

-	<target name="mac" description="Builds jni/linux">

-		<ant dir="mac" inheritall="false"/>

-	</target>

-

-	<target name="clean" description="Cleans this project's intermediate and output files">

-		<delete dir="${project.build}" failonerror="false" />

-	</target>

-

-	<target name="all" depends="linux,windows,mac" description="Builds all platforms" />

-

+	<property name="project.tail" value="jni" />

+	<import file="${gwt.root}/platforms.ant.xml" />

 </project>

diff --git a/jni/linux/build.xml b/jni/linux/build.xml
index db0db0f..f0be89a 100755
--- a/jni/linux/build.xml
+++ b/jni/linux/build.xml
@@ -1,4 +1,4 @@
-<project name="jni-linux" default="all" basedir=".">

+<project name="jni-linux" default="build" basedir=".">

 	<property name="gwt.root" location="../.." />

 	<property name="project.tail" value="jni/linux" />

 	<import file="${gwt.root}/common.ant.xml" />

@@ -15,6 +15,4 @@
 		<delete dir="${project.build}" failonerror="false" />

 		<delete dir="${project.jni}" failonerror="false" />

 	</target>

-

-	<target name="all" depends="build" description="Builds and packages this project" />

 </project>

diff --git a/jni/mac/build.xml b/jni/mac/build.xml
index 37146d8..6526780 100755
--- a/jni/mac/build.xml
+++ b/jni/mac/build.xml
@@ -1,4 +1,4 @@
-<project name="jni-mac" default="all" basedir=".">

+<project name="jni-mac" default="build" basedir=".">

 	<property name="gwt.root" location="../.." />

 	<property name="project.tail" value="jni/mac" />

 	<import file="${gwt.root}/common.ant.xml" />

@@ -15,6 +15,4 @@
 		<delete dir="${project.build}" failonerror="false" />

 		<delete dir="${project.jni}" failonerror="false" />

 	</target>

-

-	<target name="all" depends="build" description="Builds and packages this project" />

 </project>

diff --git a/jni/windows/build.xml b/jni/windows/build.xml
index 9c65e9a..20b1b66 100755
--- a/jni/windows/build.xml
+++ b/jni/windows/build.xml
@@ -1,4 +1,4 @@
-<project name="jni-windows" default="all" basedir=".">

+<project name="jni-windows" default="build" basedir=".">

 	<property name="gwt.root" location="../.." />

 	<property name="project.tail" value="jni/windows" />

 	<import file="${gwt.root}/common.ant.xml" />

@@ -15,6 +15,4 @@
 		<delete dir="${project.build}" failonerror="false" />

 		<delete dir="${project.jni}" failonerror="false" />

 	</target>

-

-	<target name="all" depends="build" description="Builds and packages this project" />

 </project>

diff --git a/platforms.ant.xml b/platforms.ant.xml
new file mode 100755
index 0000000..4e1bb0f
--- /dev/null
+++ b/platforms.ant.xml
@@ -0,0 +1,44 @@
+<project name="platforms">

+	<import file="${gwt.root}/common.ant.xml" />

+

+	<!-- "build" is the default when subprojects are directly targetted -->

+	<property name="target" value="build" />

+

+	<available file="core/build.xml" type="file" property="core.exists" />

+	<target name="core" description="Run core" if="core.exists">

+		<ant dir="core" inheritall="false" target="${target}" />

+	</target>

+

+	<target name="linux" depends="core" description="Run linux">

+		<ant dir="linux" inheritall="false" target="${target}" />

+	</target>

+

+	<target name="windows" depends="core" description="Run windows">

+		<ant dir="windows" inheritall="false" target="${target}" />

+	</target>

+

+	<target name="mac" depends="core" description="Run mac">

+		<ant dir="mac" inheritall="false" target="${target}" />

+	</target>

+

+	<target name="-do" depends="linux, windows, mac" description="Run all platforms" />

+

+	<target name="build" description="Build each platforms">

+		<antcall target="-do">

+			<param name="target" value="build" />

+		</antcall>

+	</target>

+

+	<target name="checkstyle" description="Static analysis of source for each platform">

+		<antcall target="-do">

+			<param name="target" value="checkstyle" />

+		</antcall>

+	</target>

+

+	<target name="test" depends="build" description="Test each platform">

+		<antcall target="-do">

+			<param name="target" value="test" />

+		</antcall>

+	</target>

+

+</project>

diff --git a/servlet/build.xml b/servlet/build.xml
index a5d5975..3318736 100755
--- a/servlet/build.xml
+++ b/servlet/build.xml
@@ -1,13 +1,13 @@
-<project name="servlet" default="all" basedir=".">

+<project name="servlet" default="build" basedir=".">

 	<property name="gwt.root" location=".." />

-	<property name="project.tail" value="servlet" />
+	<property name="project.tail" value="servlet" />

 	<import file="${gwt.root}/common.ant.xml" />

 

 	<property.ensure name="gwt.user.root" location="${gwt.root}/user" />

 	<property.ensure name="gwt.user.build" location="${gwt.build.out}/user" />

 	<property.ensure name="gwt.user.bin" location="${gwt.user.build}/bin" />

 

-	<target name="package" description="Packages this project into a jar">

+	<target name="build" description="Packages this project into a jar">

 		<mkdir dir="${gwt.build.lib}" />

 		<gwt.jar>

 			<fileset dir="${gwt.user.bin}">

@@ -26,14 +26,7 @@
 		</gwt.jar>

 	</target>

 

-	<target name="verify" description="Static analysis of source">

-		<!-- nothing to do -->

-	</target>

-

 	<target name="clean" description="Cleans this project's intermediate and output files">

 		<delete file="${project.lib}" />

 	</target>

-

-	<target name="all" depends="package" description="Build and packages this project" />

-

 </project>

diff --git a/user/build.xml b/user/build.xml
index abf343a..0e0b490 100755
--- a/user/build.xml
+++ b/user/build.xml
@@ -1,6 +1,6 @@
-<project name="user" default="all" basedir=".">

+<project name="user" default="build" basedir=".">

 	<property name="gwt.root" location=".." />

-	<property name="project.tail" value="user" />
+	<property name="project.tail" value="user" />

 	<import file="${gwt.root}/common.ant.xml" />

 

 	<property.ensure name="gwt.core.root" location="${gwt.root}/dev/core" />

@@ -17,7 +17,7 @@
 				<pathelement location="${gwt.tools.lib}/eclipse/org.eclipse.swt.gtk-linux-3.2.1.jar" />

 			</classpath>

 		</gwt.javac>

-	</target>
+	</target>

 

 	<target name="package" depends="build" description="Packages this project into a jar">

 		<mkdir dir="${gwt.build.lib}" />

@@ -28,7 +28,7 @@
 		</gwt.jar>

 	</target>

 

-	<target name="verify" description="Static analysis of source">

+	<target name="checkstyle" description="Static analysis of source">

 		<gwt.checkstyle>

 			<fileset dir="super/com/google/gwt/emul"/>

 			<fileset dir="super/com/google/gwt/junit/translatable"/>

@@ -40,6 +40,4 @@
 		<delete file="${project.lib}" />

 	</target>

 

-	<target name="all" depends="package" description="Build and packages this project" />

-

 </project>