blob: c01d2788581eedf0f09a9d5093710040fd669f64 [file] [log] [blame]
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +00001<project name="common">
2 <property name="test.ant.file" location="${gwt.root}/${project.tail}/build.xml" />
3 <condition property="project.valid">
4 <equals arg1="${ant.file}" arg2="${test.ant.file}" />
5 </condition>
6 <fail unless="project.valid" message="This build file is in an inconsistent state." />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +00007
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +00008 <!-- Global Properties -->
9 <property environment="env" />
10 <condition property="gwt.version" value="${env.GWT_VERSION}" else="0.0.0">
11 <isset property="env.GWT_VERSION" />
12 </condition>
13 <condition property="gwt.tools.check" value="${env.GWT_TOOLS}" else="${gwt.root}/../tools">
14 <isset property="env.GWT_TOOLS" />
15 </condition>
16 <property name="gwt.tools" location="${gwt.tools.check}" />
17 <property name="gwt.tools.lib" location="${gwt.tools}/lib" />
18 <property name="gwt.tools.antlib" location="${gwt.tools}/antlib" />
19 <property name="gwt.tools.redist" location="${gwt.tools}/redist" />
20 <property name="gwt.build" location="${gwt.root}/build" />
21 <property name="gwt.build.out" location="${gwt.build}/out" />
22 <property name="gwt.build.lib" location="${gwt.build}/lib" />
23 <property name="gwt.build.jni" location="${gwt.build}/jni" />
24 <property name="gwt.build.staging" location="${gwt.build}/staging" />
25 <property name="gwt.build.dist" location="${gwt.build}/dist" />
26 <property name="project.build" location="${gwt.build.out}/${project.tail}" />
27 <property name="project.lib" location="${gwt.build.lib}/gwt-${ant.project.name}.jar" />
28 <property name="project.jni" location="${gwt.build}/${project.tail}" />
29 <property name="unjar.out" location="${project.build}/unjar" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000030 <property name="javac.out" location="${project.build}/bin" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000031 <property name="javac.junit.out" location="${project.build}/bin-test" />
32 <property name="javac.debug" value="true" />
33 <property name="javac.debuglevel" value="lines,vars,source" />
gwt.team.mmendez14e28a22006-12-11 04:34:27 +000034 <property name="javac.encoding" value="utf-8" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000035 <property name="javac.source" value="1.4" />
36 <property name="javac.nowarn" value="true" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000037 <property name="junit.out" location="${project.build}/test" />
gwt.team.scottba4f285c2006-12-09 02:11:15 +000038
gwt.team.scottb193a3b92006-12-11 22:24:38 +000039 <!-- Sanity check -->
40 <available file="${gwt.tools}" type="dir" property="gwt.tools.exists" />
41 <fail unless="gwt.tools.exists" message="Cannot find '${gwt.tools}' tools directory; perhaps you should define the GWT_TOOLS environment variable" />
42
43 <!-- JUnit support -->
44 <condition property="build.host.platform" value="linux">
45 <and>
46 <os family="unix" />
47 <not>
48 <contains string="${os.name}" substring="mac" casesensitive="false" />
49 </not>
50 </and>
51 </condition>
52
53 <condition property="build.host.platform" value="mac">
54 <and>
55 <os family="unix" />
56 <contains string="${os.name}" substring="mac" casesensitive="false" />
57 </and>
58 </condition>
59
60 <condition property="build.host.platform" value="windows">
61 <os family="windows" />
62 </condition>
63 <fail unless="build.host.platform" message="Building on ${os.name} is not supported" />
64
65 <condition property="junit.platform.args" value="-XstartOnFirstThread" else="">
66 <equals arg1="${build.host.platform}" arg2="mac" casesensitive="false" />
67 </condition>
68
gwt.team.scottba4f285c2006-12-09 02:11:15 +000069 <property name="gwt.dev.staging.jar" location="${gwt.build.staging}/gwt-${build.host.platform}-${gwt.version}/gwt-dev-${build.host.platform}.jar" />
70 <property name="gwt.junit.port" value="8888" />
71
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000072 <!--
73 Comma delimited list of host and path components on which to run remote browser testing.
74 -->
gwt.team.scottba4f285c2006-12-09 02:11:15 +000075 <property name="gwt.remote.browsers" value="" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000076
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000077
78 <!-- Pulls in tasks defined in ant-contrib, i.e. foreach -->
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000079 <taskdef resource="net/sf/antcontrib/antlib.xml">
gwt.team.scottba4f285c2006-12-09 02:11:15 +000080 <classpath>
81 <pathelement location="${gwt.tools.antlib}/ant-contrib-1.0b3.jar" />
82 </classpath>
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000083 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000084
85 <!-- Global Custom Tasks -->
86 <presetdef name="gwt.ant">
87 <ant inheritall="false" target="${target}">
88 <propertyset>
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000089 <propertyref name="gwt.version" />
90 <propertyref name="gwt.junit.port" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000091 <propertyref name="gwt.remote.browsers" />
92 </propertyset>
93 </ant>
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000094 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000095
96 <presetdef name="gwt.javac">
gwt.team.mmendez14e28a22006-12-11 04:34:27 +000097 <javac srcdir="src" destdir="${javac.out}" classpath="${unjar.out}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.source}" nowarn="${javac.nowarn}" encoding="${javac.encoding}" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000098 </presetdef>
99
100 <presetdef name="gwt.jar">
101 <jar destfile="${project.lib}" update="true" duplicate="preserve" index="true" />
102 </presetdef>
103
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000104 <macrodef name="gwt.junit">
105 <attribute name="test.args" default="" />
106 <attribute name="test.out" default="" />
107 <attribute name="test.reports" default="@{test.out}/reports" />
108 <attribute name="test.cases" default="" />
gwt.team.scottba4f285c2006-12-09 02:11:15 +0000109 <sequential>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000110 <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
111 <classpath>
112 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
113 <pathelement location="${gwt.tools.antlib}/ant-junit-1.6.5.jar" />
114 </classpath>
115 </taskdef>
116
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000117 <echo message="Writing test results to @{test.reports} for @{test.cases}" />
gwt.team.scottba4f285c2006-12-09 02:11:15 +0000118 <mkdir dir="@{test.reports}" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000119
gwt.team.scottba4f285c2006-12-09 02:11:15 +0000120 <echo message="${javac.out} ${javac.junit.out}" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000121 <junit dir="@{test.out}" fork="yes" printsummary="yes" haltonfailure="true">
gwt.team.scottb193a3b92006-12-11 22:24:38 +0000122 <jvmarg line="${junit.platform.args}" />
gwt.team.scottba4f285c2006-12-09 02:11:15 +0000123 <sysproperty key="gwt.args" value="@{test.args}" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000124 <sysproperty key="gwt.devjar" value="${gwt.dev.staging.jar}" />
125 <sysproperty key="java.awt.headless" value="true" />
126
127 <classpath>
128 <pathelement location="${gwt.root}/${project.tail}/src" />
129 <pathelement location="${gwt.root}/${project.tail}/super" />
130 <pathelement location="${gwt.root}/${project.tail}/test" />
131 <pathelement location="${javac.junit.out}" />
132 <pathelement location="${javac.out}" />
133 <pathelement location="${gwt.dev.staging.jar}" />
134 </classpath>
135
136 <formatter type="plain" />
137 <formatter type="xml" />
138
139 <batchtest todir="@{test.reports}">
140 <fileset refid="@{test.cases}" />
141 </batchtest>
142 </junit>
143 </sequential>
144 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000145
146 <macrodef name="gwt.untar">
147 <attribute name="src" />
148 <attribute name="dest" />
149 <sequential>
150 <!-- GNU tar handles permissions and symlinks correctly -->
151 <exec executable="tar" failonerror="true">
152 <arg value="-xpzf" />
153 <arg file="@{src}" />
154 <arg value="-C" />
155 <arg file="@{dest}" />
156 </exec>
157 </sequential>
158 </macrodef>
159
gwt.team.scottbb5aba972006-12-10 06:07:09 +0000160 <target name="-unjar.maybe" unless="unjar.upToDate">
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000161 <mkdir dir="${unjar.out}" />
162 <unjar src="${unjar.path}" dest="${unjar.out}" overwrite="true" />
163 <touch file="${unjar.flagFile}" />
164 </target>
165
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000166 <macrodef name="gwt.unjar">
167 <attribute name="toollib" default="" />
168 <attribute name="path" default="${gwt.tools.lib}/@{toollib}" />
169 <sequential>
gwt.team.scottbb5aba972006-12-10 06:07:09 +0000170 <basename property="@{path}.unjar.name" file="@{path}" />
171 <property name="@{path}.unjar.flagFile" value="${project.build}/${@{path}.unjar.name}.unjar" />
172 <uptodate property="@{path}.unjar.upToDate" value="unjar.upToDate" srcfile="@{path}" targetfile="${@{path}.unjar.flagFile}" />
173 <antcall target="-unjar.maybe">
174 <param name="${@{path}.unjar.upToDate}" value="true" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000175 <param name="unjar.path" value="@{path}" />
gwt.team.scottbb5aba972006-12-10 06:07:09 +0000176 <param name="unjar.flagFile" value="${@{path}.unjar.flagFile}" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000177 </antcall>
178 </sequential>
179 </macrodef>
180
181 <macrodef name="property.ensure">
182 <attribute name="name" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000183 <attribute name="location" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000184 <attribute name="message" default="Cannot find dependency ${@{name}}" />
185 <sequential>
186 <property name="@{name}" location="@{location}" />
187 <available file="${@{name}}" property="@{name}.exists" />
188 <fail unless="@{name}.exists" message="@{message}" />
189 </sequential>
190 </macrodef>
191
192 <macrodef name="gwt.checkstyle">
193 <element name="sourcepath" implicit="yes" optional="true" />
194 <sequential>
195 <taskdef resource="checkstyletask.properties" classpath="${gwt.tools.antlib}/checkstyle-all-4.2.jar;${gwt.build.lib}/gwt-customchecks.jar" />
196 <checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle.xml" maxWarnings="0">
197 <property key="checkstyle.header.file" file="${gwt.root}/eclipse/settings/code-style/google.header" />
198 <sourcepath />
199 </checkstyle>
200 </sequential>
201 </macrodef>
202
203 <!-- Default implementations of the required targets; projects should
204 override the ones that matter -->
205 <target name="all" depends="verify" />
206 <target name="verify" depends="checkstyle, test" description="Verify this project" />
207 <target name="checkstyle" description="Static analysis of source" />
208 <target name="test" depends="build" description="Test this project" />
209 <target name="build" description="Build and (maybe) package this project" />
210
211 <target name="clean" description="Cleans this project's intermediate and output files">
212 <delete dir="${project.build}" />
213 </target>
214
215</project>