blob: db7a41144ae35a8bafb93952f016df44f44a79d7 [file] [log] [blame]
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +00001<project name="common">
fabbott@google.com25305472009-06-10 21:39:00 +00002 <!-- it's okay for this not to exist, but it gives a place to store
3 "your" property settings, if any, persistently. For example, you
4 might use it to set gwt.junit.testcase.includes to a narrower subset
5 of test cases to exercise. -->
6 <property file="local.ant.properties" />
7
fabbott@google.com0e2dc6282008-08-22 16:09:01 +00008 <!-- gwt.build.iscasesensitivefs is true if the filesystem of the
9 build machine is case-sensitive, false otherwise. Update with
10 new lines for any supported platforms with case-insensitive
11 filesystems
12 -->
13 <condition property="gwt.build.iscasesensitivefs" else="false">
14 <not>
15 <or>
16 <os family="windows"/>
17 </or>
18 </not>
19 </condition>
gwt.team.jatceab1ec2006-12-28 22:48:49 +000020
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000021 <property name="test.ant.file" location="${gwt.root}/${project.tail}/build.xml" />
22 <condition property="project.valid">
23 <equals arg1="${ant.file}" arg2="${test.ant.file}"
24 casesensitive="${gwt.build.iscasesensitivefs}"/>
25 </condition>
26 <fail unless="project.valid" message="This build file is in an inconsistent state (${ant.file} != ${test.ant.file})." />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +000027
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000028 <!-- Global Properties -->
29 <property environment="env" />
30 <condition property="gwt.version" value="${env.GWT_VERSION}" else="0.0.0">
31 <isset property="env.GWT_VERSION" />
32 </condition>
33 <condition property="gwt.tools.check" value="${env.GWT_TOOLS}" else="${gwt.root}/../tools">
34 <isset property="env.GWT_TOOLS" />
35 </condition>
36 <property name="gwt.tools" location="${gwt.tools.check}" />
37 <property name="gwt.tools.lib" location="${gwt.tools}/lib" />
38 <property name="gwt.tools.antlib" location="${gwt.tools}/antlib" />
39 <property name="gwt.tools.redist" location="${gwt.tools}/redist" />
40 <property name="gwt.build" location="${gwt.root}/build" />
41 <property name="gwt.build.out" location="${gwt.build}/out" />
42 <property name="gwt.build.lib" location="${gwt.build}/lib" />
43 <property name="gwt.build.jni" location="${gwt.build}/jni" />
44 <property name="gwt.build.staging" location="${gwt.build}/staging" />
45 <property name="gwt.build.dist" location="${gwt.build}/dist" />
bobv@google.comb2bd3f52009-02-19 23:38:40 +000046 <property name="gwt.threadsPerProcessor" value="1" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000047 <property name="project.build" location="${gwt.build.out}/${project.tail}" />
48 <property name="project.lib" location="${gwt.build.lib}/gwt-${ant.project.name}.jar" />
49 <property name="project.jni" location="${gwt.build}/${project.tail}" />
50 <property name="javac.out" location="${project.build}/bin" />
51 <property name="javac.junit.out" location="${project.build}/bin-test" />
jlabanca@google.com81244562009-08-05 19:55:36 +000052 <property name="javac.emma.out" location="${project.build}/bin-emma" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000053 <property name="javac.debug" value="true" />
54 <property name="javac.debuglevel" value="lines,vars,source" />
55 <property name="javac.encoding" value="utf-8" />
56 <property name="javac.source" value="1.5" />
57 <property name="javac.target" value="1.5" />
58 <property name="javac.nowarn" value="true" />
59 <property name="junit.out" location="${project.build}/test" />
jlabanca@google.com81244562009-08-05 19:55:36 +000060 <property name="emma.dir" value="${gwt.tools.redist}/emma" />
61 <property name="emma.filter.exclude" value="" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000062
63 <!-- Sanity check -->
64 <available file="${gwt.tools}" type="dir" property="gwt.tools.exists" />
65 <fail unless="gwt.tools.exists" message="Cannot find '${gwt.tools}' tools directory; perhaps you should define the GWT_TOOLS environment variable" />
gwt.team.scottb193a3b92006-12-11 22:24:38 +000066
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000067 <!-- Platform identification -->
68 <condition property="build.host.islinux">
69 <and>
70 <os family="unix" />
71 <not>
72 <contains string="${os.name}" substring="mac" casesensitive="false" />
73 </not>
74 </and>
75 </condition>
76 <condition property="build.host.platform" value="linux">
77 <isset property="build.host.islinux" />
78 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000079
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000080 <condition property="build.host.ismac">
81 <and>
82 <os family="unix" />
83 <contains string="${os.name}" substring="mac" casesensitive="false" />
84 </and>
85 </condition>
86 <condition property="build.host.platform" value="mac">
87 <isset property="build.host.ismac" />
88 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000089
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000090 <condition property="build.host.iswindows">
91 <os family="windows" />
92 </condition>
93 <condition property="build.host.platform" value="windows">
94 <isset property="build.host.iswindows" />
95 </condition>
96 <fail unless="build.host.platform" message="Building on ${os.name} is not supported" />
gwt.team.scottb193a3b92006-12-11 22:24:38 +000097
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000098 <condition property="junit.platform.args" value="-XstartOnFirstThread" else="">
99 <isset property="build.host.ismac" />
100 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +0000101
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000102 <!-- JUnit support -->
103 <property name="gwt.dev.staging.jar" location="${gwt.build.staging}/gwt-${build.host.platform}-${gwt.version}/gwt-dev-${build.host.platform}.jar" />
104 <property name="gwt.junit.port" value="8888" />
105 <property name="gwt.junit.testcase.includes" value="**/*Suite.class"/>
gwt.team.zundel910448e2008-04-26 13:56:28 +0000106
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000107 <!-- Headless mode keeps the hosted mode browser and log window
108 from popping up during a unit test run. This is usually desirable,
109 but the WebKit layout engine performs some optimizations in
110 headless mode that causes some GWT unit tests to break. The
111 solution for the time being is to turn off headless mode on
112 the mac.
113 -->
114 <condition property="junit.headless">
115 <not>
116 <isset property="build.host.ismac" />
117 </not>
118 </condition>
119 <condition property="junit.notheadless.arg" value="-notHeadless" else="">
120 <not>
121 <isset property="junit.headless" />
122 </not>
123 </condition>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000124
jlabanca@google.com81244562009-08-05 19:55:36 +0000125 <!-- Shared class paths -->
126 <path id="project.classpath.class">
127 <pathelement location="${javac.out}" />
128 </path>
129 <path id="project.classpath.src">
130 <pathelement location="${gwt.root}/${project.tail}/src" />
131 </path>
132
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000133 <!-- Pulls in tasks defined in ant-contrib, i.e. foreach -->
134 <taskdef resource="net/sf/antcontrib/antlib.xml">
135 <classpath>
136 <pathelement location="${gwt.tools.antlib}/ant-contrib-1.0b3.jar" />
137 </classpath>
138 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000139
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000140 <!-- Global Custom Tasks -->
141 <presetdef name="gwt.ant">
142 <ant inheritall="false" target="${target}">
143 <propertyset>
144 <propertyref name="gwt.version" />
145 <propertyref name="gwt.junit.port" />
146 <propertyref name="gwt.remote.browsers" />
jlabanca@google.com81244562009-08-05 19:55:36 +0000147 <propertyref name="emma.enabled" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000148 </propertyset>
149 </ant>
150 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000151
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000152 <presetdef name="gwt.javac">
153 <javac srcdir="src" destdir="${javac.out}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.source}" target="${javac.target}" nowarn="${javac.nowarn}" encoding="${javac.encoding}" />
154 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000155
fabbott@google.com25305472009-06-10 21:39:00 +0000156 <macrodef name="gwt.jar">
157 <attribute name="destfile" default="${project.lib}"/>
158 <attribute name="duplicate" default="fail"/>
159 <attribute name="update" default="true"/>
160 <element name="jarcontents" implicit="true"/>
161 <sequential>
162 <taskdef name="jar.bydate"
163 classname="com.google.gwt.ant.taskdefs.LatestTimeJar"
164 classpath="${gwt.build.lib}/ant-gwt.jar" />
165
166 <jar.bydate destfile="@{destfile}" duplicate="@{duplicate}" filesonly="false"
167 index="true" update="@{update}">
168 <jarcontents/>
169 </jar.bydate>
170 </sequential>
171 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000172
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000173 <macrodef name="gwt.junit">
174 <!-- TODO: make this more generic / refactor so it can be used from dev/core -->
amitmanjhi@google.comcc68e232009-07-22 17:25:37 +0000175 <attribute name="test.args" default="" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000176 <attribute name="test.out" default="" />
177 <attribute name="test.reports" default="@{test.out}/reports" />
jlabanca@google.com81244562009-08-05 19:55:36 +0000178 <attribute name="test.emma.coverage" default="@{test.out}/emma-coverage" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000179 <attribute name="test.cases" default="" />
180 <element name="extraclasspaths" optional="true" />
181 <sequential>
182 <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
183 <classpath>
184 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
185 <pathelement location="${gwt.tools.antlib}/ant-junit-1.6.5.jar" />
186 <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
187 </classpath>
188 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000189
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000190 <echo message="Writing test results to @{test.reports} for @{test.cases}" />
191 <mkdir dir="@{test.reports}" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000192
jlabanca@google.com81244562009-08-05 19:55:36 +0000193 <antcall target="-create.emma.coverage">
194 <param name="test.emma.coverage" value="@{test.emma.coverage}"/>
195 </antcall>
196 <condition property="emma.lib" value="${emma.dir}/emma-2.0.5312-patched.jar" else="">
197 <isset property="emma.enabled" />
198 </condition>
199
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000200 <echo message="${javac.out} ${javac.junit.out}" />
fabbott@google.comf87faf12009-06-17 15:33:38 +0000201 <junit dir="@{test.out}" fork="yes" printsummary="yes"
jlabanca@google.com1426e812009-08-06 21:05:34 +0000202 failureproperty="junit.failure" tempdir="@{test.out}"
203 showoutput="yes">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000204 <jvmarg line="${junit.platform.args}" />
jat@google.com633cf172009-03-27 06:08:37 +0000205 <jvmarg line="-Xmx768m" />
jlabanca@google.com81244562009-08-05 19:55:36 +0000206 <jvmarg value="-Demma.coverage.out.file=@{test.emma.coverage}/coverage.emma" />
207 <jvmarg value="-Demma.coverage.out.merge=true" />
amitmanjhi@google.com6146b0c2009-07-25 14:55:48 +0000208 <sysproperty key="gwt.args" value="${junit.notheadless.arg} @{test.args}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000209 <sysproperty key="java.awt.headless" value="${junit.headless}" />
210 <sysproperty key="gwt.devjar" value="${gwt.dev.staging.jar}" />
211 <classpath>
jlabanca@google.com81244562009-08-05 19:55:36 +0000212 <path refid="project.classpath.src" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000213 <pathelement location="${gwt.root}/${project.tail}/super" />
214 <pathelement location="${gwt.root}/${project.tail}/test" />
215 <pathelement location="${javac.junit.out}" />
jlabanca@google.com81244562009-08-05 19:55:36 +0000216 <!-- javac.emma.out is empty unless emma is enabled. -->
217 <pathelement location="${javac.emma.out}" />
218 <path refid="project.classpath.class" />
219 <pathelement location="${emma.lib}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000220 <pathelement location="${gwt.dev.staging.jar}" />
221 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
222 <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
bobv@google.coma933c8b2009-03-26 02:12:25 +0000223 <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
224 <pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3.jar" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000225 <extraclasspaths />
226 </classpath>
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000227
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000228 <formatter type="plain" />
229 <formatter type="xml" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000230
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000231 <batchtest todir="@{test.reports}">
232 <fileset refid="@{test.cases}" />
233 </batchtest>
234 </junit>
jlabanca@google.com81244562009-08-05 19:55:36 +0000235
236 <emma enabled="${emma.enabled}">
237 <report sourcepath="${project.classpath.src}">
238 <fileset file="${javac.emma.out}/metadata.emma" />
239 <fileset dir="@{test.emma.coverage}">
240 <include name="*.emma" />
241 </fileset>
242 <txt outfile="@{test.emma.coverage}/coverage.txt" />
243 <html outfile="@{test.emma.coverage}/coverage.html" />
244 <xml outfile="@{test.emma.coverage}/coverage.xml" />
245 </report>
246 </emma>
247
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000248 <fail message="One or more junit tests failed" if="junit.failure" />
249 </sequential>
250 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000251
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000252 <macrodef name="gwt.tgz.cat">
253 <attribute name="destfile" />
254 <attribute name="compression" default="gzip" />
255 <element name="tar.elements" implicit="true" optional="true" />
256 <sequential>
257 <taskdef name="tar.cat" classname="com.google.gwt.ant.taskdefs.TarCat" classpath="${gwt.build.lib}/ant-gwt.jar" />
258 <tar.cat destfile="@{destfile}" compression="@{compression}" longfile="gnu">
259 <tar.elements />
260 </tar.cat>
261 </sequential>
262 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000263
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000264 <macrodef name="gwt.getsvninfo" description="Identifies the SVN info of a workspace">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000265 <sequential>
fabbott@google.com66b79062008-09-20 05:44:47 +0000266 <taskdef name="svninfo"
267 classname="com.google.gwt.ant.taskdefs.SvnInfo"
268 classpath="${gwt.build.lib}/ant-gwt.jar" />
fabbott@google.com4e4f3632008-09-23 01:15:55 +0000269 <svninfo directory="${gwt.root}" outputproperty="gwt.svnrev"
fabbott@google.com66b79062008-09-20 05:44:47 +0000270 outputfileproperty="gwt.svnrev.filename" />
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000271 <!-- Generally, filtering requires a sentinel file so that changes to svn rev will
272 be noticed as invalidating the previously-generated filter output. This property
273 names where such a sentinel lives; it is tested with <available/> and created
274 with <touch/> -->
275 <mkdir dir="${project.build}/sentinels" />
276 <property name="filter.sentinel"
277 location="${project.build}/sentinels/gwt-${gwt.version}-svn-${gwt.svnrev.filename}" />
278 </sequential>
279 </macrodef>
280
281 <macrodef name="gwt.revfilter" description="Filters files for versioning">
282 <attribute name="todir" description="Destination for the filtered copy"/>
283
284 <element name="src.fileset" implicit="true"
285 description="Source for the filtered copy"/>
286 <sequential>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000287 <!-- These files must be filtered for versioning -->
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000288 <echo message="Branding as GWT version ${gwt.version}, SVN rev ${gwt.svnrev}"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000289 <mkdir dir="@{todir}" />
290 <copy todir="@{todir}" overwrite="true">
291 <src.fileset/>
292 <filterset>
293 <filter token="GWT_VERSION" value="${gwt.version}" />
294 <filter token="GWT_SVNREV" value="${gwt.svnrev}" />
295 </filterset>
296 </copy>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000297 </sequential>
298 </macrodef>
fabbott@google.com4a87ea12008-08-20 21:02:23 +0000299
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000300 <macrodef name="gwt.timer">
301 <attribute name="name"/>
302 <element name="timer.elements" implicit="true" optional="false"/>
303 <sequential>
304 <taskdef name="timer"
305 classname="com.google.gwt.ant.taskdefs.Timer"
306 classpath="${gwt.build.lib}/ant-gwt.jar" />
307 <timer name="@{name}">
308 <timer.elements/>
309 </timer>
310 </sequential>
311 </macrodef>
fabbott@google.comf8284cd2008-05-09 20:14:51 +0000312
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000313 <macrodef name="gwt.checkstyle">
fabbott@google.com615a29b2009-06-23 16:20:54 +0000314 <attribute name="outputdirectory" default="${project.build}"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000315 <element name="sourcepath" implicit="yes" optional="true" />
316 <sequential>
317 <taskdef resource="checkstyletask.properties" classpath="${gwt.tools.antlib}/checkstyle-all-4.2.jar;${gwt.build.lib}/gwt-customchecks.jar" />
fabbott@google.com61094352009-07-11 02:18:10 +0000318 <mkdir dir="@{outputdirectory}"/>
fabbott@google.com615a29b2009-06-23 16:20:54 +0000319 <checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle.xml" maxErrors="0" failOnViolation="false" failureProperty="gwt.checkstyle.failed">
320 <formatter type="xml" toFile="@{outputdirectory}/checkstyle_log.xml"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000321 <property key="checkstyle.header.file" file="${gwt.root}/eclipse/settings/code-style/google.header" />
322 <sourcepath />
323 </checkstyle>
fabbott@google.com615a29b2009-06-23 16:20:54 +0000324 <fail message="Checkstyle errors exist, and are reported in checkstyle_log.xml located at @{outputdirectory}" if="gwt.checkstyle.failed" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000325 </sequential>
326 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000327
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000328 <macrodef name="property.ensure">
329 <attribute name="name" />
330 <attribute name="location" />
331 <attribute name="message" default="Cannot find dependency ${@{name}}" />
332 <attribute name="unless" default="__nonexistent_property__" />
333 <sequential>
334 <property name="@{name}" location="@{location}" />
335 <condition property="@{name}.exists">
336 <or>
337 <available file="${@{name}}" />
338 <isset property="@{unless}" />
339 </or>
340 </condition>
341 <fail unless="@{name}.exists" message="@{message}" />
342 </sequential>
343 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000344
jlabanca@google.com81244562009-08-05 19:55:36 +0000345 <!-- Targets for emma support. To run tests with emma enabled, use
346 ant <test-target> -Demma.enabled=true -->
347 <path id="emma.taskdef.lib">
348 <pathelement location="${emma.dir}/emma-2.0.5312-patched.jar" />
349 <pathelement location="${emma.dir}/emma_ant-2.0.5312.jar" />
350 </path>
351
352 <taskdef resource="emma_ant.properties" classpathref="emma.taskdef.lib" />
353
354 <target name="compile.emma" description="Instruments emma classes" unless="emma.compiled">
355 <delete dir="${javac.emma.out}" />
356 <property name="emma.compiled" value="true" />
357 <antcall target="-compile.emma.if.enabled" />
358 </target>
359
360 <target name="-compile.emma.if.enabled" description="Instruments emma classes" if="emma.enabled">
361 <mkdir dir="${javac.emma.out}" />
362 <path id="emma.classpath">
363 <pathelement location="${javac.out}" />
364 </path>
365 <emma enabled="${emma.enabled}" >
366 <instr instrpathref="emma.classpath" destdir="${javac.emma.out}" metadatafile="${javac.emma.out}/metadata.emma" merge="false">
367 <filter includes="com.google.*" />
368 <filter excludes="${emma.filter.exclude}" />
369 </instr>
370 </emma>
371 </target>
372
373 <target name="-create.emma.coverage" description="Create the emma coverage directory" if="emma.enabled">
374 <delete dir="${test.emma.coverage}" />
375 <mkdir dir="${test.emma.coverage}" />
376 </target>
377
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000378 <!-- Default implementations of the required targets; projects should
379 override the ones that matter -->
380 <target name="all" depends="verify" />
fabbott@google.com71e72af2009-06-13 02:28:21 +0000381 <target name="verify" depends="checkstyle, test" description="Runs tests and checkstyle static analysis" />
382 <target name="checkstyle" />
383 <target name="test" depends="build" />
384 <target name="build" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000385
fabbott@google.com71e72af2009-06-13 02:28:21 +0000386 <target name="clean">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000387 <delete dir="${project.build}" />
388 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000389
390</project>