blob: 37cfcce67071f918c5d75b3d2ce8573d95891ff5 [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" />
52 <property name="javac.debug" value="true" />
53 <property name="javac.debuglevel" value="lines,vars,source" />
54 <property name="javac.encoding" value="utf-8" />
55 <property name="javac.source" value="1.5" />
56 <property name="javac.target" value="1.5" />
57 <property name="javac.nowarn" value="true" />
58 <property name="junit.out" location="${project.build}/test" />
59
60 <!-- Sanity check -->
61 <available file="${gwt.tools}" type="dir" property="gwt.tools.exists" />
62 <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 +000063
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000064 <!-- Platform identification -->
65 <condition property="build.host.islinux">
66 <and>
67 <os family="unix" />
68 <not>
69 <contains string="${os.name}" substring="mac" casesensitive="false" />
70 </not>
71 </and>
72 </condition>
73 <condition property="build.host.platform" value="linux">
74 <isset property="build.host.islinux" />
75 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000076
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000077 <condition property="build.host.ismac">
78 <and>
79 <os family="unix" />
80 <contains string="${os.name}" substring="mac" casesensitive="false" />
81 </and>
82 </condition>
83 <condition property="build.host.platform" value="mac">
84 <isset property="build.host.ismac" />
85 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000086
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000087 <condition property="build.host.iswindows">
88 <os family="windows" />
89 </condition>
90 <condition property="build.host.platform" value="windows">
91 <isset property="build.host.iswindows" />
92 </condition>
93 <fail unless="build.host.platform" message="Building on ${os.name} is not supported" />
gwt.team.scottb193a3b92006-12-11 22:24:38 +000094
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000095 <condition property="junit.platform.args" value="-XstartOnFirstThread" else="">
96 <isset property="build.host.ismac" />
97 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000098
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000099 <!-- JUnit support -->
100 <property name="gwt.dev.staging.jar" location="${gwt.build.staging}/gwt-${build.host.platform}-${gwt.version}/gwt-dev-${build.host.platform}.jar" />
101 <property name="gwt.junit.port" value="8888" />
102 <property name="gwt.junit.testcase.includes" value="**/*Suite.class"/>
gwt.team.zundel910448e2008-04-26 13:56:28 +0000103
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000104 <!-- Headless mode keeps the hosted mode browser and log window
105 from popping up during a unit test run. This is usually desirable,
106 but the WebKit layout engine performs some optimizations in
107 headless mode that causes some GWT unit tests to break. The
108 solution for the time being is to turn off headless mode on
109 the mac.
110 -->
111 <condition property="junit.headless">
112 <not>
113 <isset property="build.host.ismac" />
114 </not>
115 </condition>
116 <condition property="junit.notheadless.arg" value="-notHeadless" else="">
117 <not>
118 <isset property="junit.headless" />
119 </not>
120 </condition>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000121
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000122 <!-- Pulls in tasks defined in ant-contrib, i.e. foreach -->
123 <taskdef resource="net/sf/antcontrib/antlib.xml">
124 <classpath>
125 <pathelement location="${gwt.tools.antlib}/ant-contrib-1.0b3.jar" />
126 </classpath>
127 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000128
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000129 <!-- Global Custom Tasks -->
130 <presetdef name="gwt.ant">
131 <ant inheritall="false" target="${target}">
132 <propertyset>
133 <propertyref name="gwt.version" />
134 <propertyref name="gwt.junit.port" />
135 <propertyref name="gwt.remote.browsers" />
136 </propertyset>
137 </ant>
138 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000139
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000140 <presetdef name="gwt.javac">
141 <javac srcdir="src" destdir="${javac.out}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.source}" target="${javac.target}" nowarn="${javac.nowarn}" encoding="${javac.encoding}" />
142 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000143
fabbott@google.com25305472009-06-10 21:39:00 +0000144 <macrodef name="gwt.jar">
145 <attribute name="destfile" default="${project.lib}"/>
146 <attribute name="duplicate" default="fail"/>
147 <attribute name="update" default="true"/>
148 <element name="jarcontents" implicit="true"/>
149 <sequential>
150 <taskdef name="jar.bydate"
151 classname="com.google.gwt.ant.taskdefs.LatestTimeJar"
152 classpath="${gwt.build.lib}/ant-gwt.jar" />
153
154 <jar.bydate destfile="@{destfile}" duplicate="@{duplicate}" filesonly="false"
155 index="true" update="@{update}">
156 <jarcontents/>
157 </jar.bydate>
158 </sequential>
159 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000160
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000161 <macrodef name="gwt.junit">
162 <!-- TODO: make this more generic / refactor so it can be used from dev/core -->
amitmanjhi@google.com7e8c64d2009-07-13 17:39:35 +0000163 <attribute name="test.args" default="" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000164 <attribute name="test.out" default="" />
165 <attribute name="test.reports" default="@{test.out}/reports" />
166 <attribute name="test.cases" default="" />
167 <element name="extraclasspaths" optional="true" />
168 <sequential>
169 <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
170 <classpath>
171 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
172 <pathelement location="${gwt.tools.antlib}/ant-junit-1.6.5.jar" />
173 <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
174 </classpath>
175 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000176
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000177 <echo message="Writing test results to @{test.reports} for @{test.cases}" />
178 <mkdir dir="@{test.reports}" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000179
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000180 <echo message="${javac.out} ${javac.junit.out}" />
fabbott@google.comf87faf12009-06-17 15:33:38 +0000181 <junit dir="@{test.out}" fork="yes" printsummary="yes"
182 failureproperty="junit.failure" tempdir="@{test.out}" >
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000183 <jvmarg line="${junit.platform.args}" />
jat@google.com633cf172009-03-27 06:08:37 +0000184 <jvmarg line="-Xmx768m" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000185 <sysproperty key="gwt.args" value="${junit.notheadless.arg} @{test.args}" />
186 <sysproperty key="java.awt.headless" value="${junit.headless}" />
187 <sysproperty key="gwt.devjar" value="${gwt.dev.staging.jar}" />
188 <classpath>
189 <pathelement location="${gwt.root}/${project.tail}/src" />
190 <pathelement location="${gwt.root}/${project.tail}/super" />
191 <pathelement location="${gwt.root}/${project.tail}/test" />
192 <pathelement location="${javac.junit.out}" />
193 <pathelement location="${javac.out}" />
194 <pathelement location="${gwt.dev.staging.jar}" />
195 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
196 <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
bobv@google.coma933c8b2009-03-26 02:12:25 +0000197 <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />
198 <pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3.jar" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000199 <extraclasspaths />
200 </classpath>
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000201
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000202 <formatter type="plain" />
203 <formatter type="xml" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000204
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000205 <batchtest todir="@{test.reports}">
206 <fileset refid="@{test.cases}" />
207 </batchtest>
208 </junit>
209 <fail message="One or more junit tests failed" if="junit.failure" />
210 </sequential>
211 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000212
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000213 <macrodef name="gwt.tgz.cat">
214 <attribute name="destfile" />
215 <attribute name="compression" default="gzip" />
216 <element name="tar.elements" implicit="true" optional="true" />
217 <sequential>
218 <taskdef name="tar.cat" classname="com.google.gwt.ant.taskdefs.TarCat" classpath="${gwt.build.lib}/ant-gwt.jar" />
219 <tar.cat destfile="@{destfile}" compression="@{compression}" longfile="gnu">
220 <tar.elements />
221 </tar.cat>
222 </sequential>
223 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000224
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000225 <macrodef name="gwt.getsvninfo" description="Identifies the SVN info of a workspace">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000226 <sequential>
fabbott@google.com66b79062008-09-20 05:44:47 +0000227 <taskdef name="svninfo"
228 classname="com.google.gwt.ant.taskdefs.SvnInfo"
229 classpath="${gwt.build.lib}/ant-gwt.jar" />
fabbott@google.com4e4f3632008-09-23 01:15:55 +0000230 <svninfo directory="${gwt.root}" outputproperty="gwt.svnrev"
fabbott@google.com66b79062008-09-20 05:44:47 +0000231 outputfileproperty="gwt.svnrev.filename" />
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000232 <!-- Generally, filtering requires a sentinel file so that changes to svn rev will
233 be noticed as invalidating the previously-generated filter output. This property
234 names where such a sentinel lives; it is tested with <available/> and created
235 with <touch/> -->
236 <mkdir dir="${project.build}/sentinels" />
237 <property name="filter.sentinel"
238 location="${project.build}/sentinels/gwt-${gwt.version}-svn-${gwt.svnrev.filename}" />
239 </sequential>
240 </macrodef>
241
242 <macrodef name="gwt.revfilter" description="Filters files for versioning">
243 <attribute name="todir" description="Destination for the filtered copy"/>
244
245 <element name="src.fileset" implicit="true"
246 description="Source for the filtered copy"/>
247 <sequential>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000248 <!-- These files must be filtered for versioning -->
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000249 <echo message="Branding as GWT version ${gwt.version}, SVN rev ${gwt.svnrev}"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000250 <mkdir dir="@{todir}" />
251 <copy todir="@{todir}" overwrite="true">
252 <src.fileset/>
253 <filterset>
254 <filter token="GWT_VERSION" value="${gwt.version}" />
255 <filter token="GWT_SVNREV" value="${gwt.svnrev}" />
256 </filterset>
257 </copy>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000258 </sequential>
259 </macrodef>
fabbott@google.com4a87ea12008-08-20 21:02:23 +0000260
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000261 <macrodef name="gwt.timer">
262 <attribute name="name"/>
263 <element name="timer.elements" implicit="true" optional="false"/>
264 <sequential>
265 <taskdef name="timer"
266 classname="com.google.gwt.ant.taskdefs.Timer"
267 classpath="${gwt.build.lib}/ant-gwt.jar" />
268 <timer name="@{name}">
269 <timer.elements/>
270 </timer>
271 </sequential>
272 </macrodef>
fabbott@google.comf8284cd2008-05-09 20:14:51 +0000273
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000274 <macrodef name="gwt.checkstyle">
fabbott@google.com615a29b2009-06-23 16:20:54 +0000275 <attribute name="outputdirectory" default="${project.build}"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000276 <element name="sourcepath" implicit="yes" optional="true" />
277 <sequential>
278 <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 +0000279 <mkdir dir="@{outputdirectory}"/>
fabbott@google.com615a29b2009-06-23 16:20:54 +0000280 <checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle.xml" maxErrors="0" failOnViolation="false" failureProperty="gwt.checkstyle.failed">
281 <formatter type="xml" toFile="@{outputdirectory}/checkstyle_log.xml"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000282 <property key="checkstyle.header.file" file="${gwt.root}/eclipse/settings/code-style/google.header" />
283 <sourcepath />
284 </checkstyle>
fabbott@google.com615a29b2009-06-23 16:20:54 +0000285 <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 +0000286 </sequential>
287 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000288
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000289 <macrodef name="property.ensure">
290 <attribute name="name" />
291 <attribute name="location" />
292 <attribute name="message" default="Cannot find dependency ${@{name}}" />
293 <attribute name="unless" default="__nonexistent_property__" />
294 <sequential>
295 <property name="@{name}" location="@{location}" />
296 <condition property="@{name}.exists">
297 <or>
298 <available file="${@{name}}" />
299 <isset property="@{unless}" />
300 </or>
301 </condition>
302 <fail unless="@{name}.exists" message="@{message}" />
303 </sequential>
304 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000305
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000306 <!-- Default implementations of the required targets; projects should
307 override the ones that matter -->
308 <target name="all" depends="verify" />
fabbott@google.com71e72af2009-06-13 02:28:21 +0000309 <target name="verify" depends="checkstyle, test" description="Runs tests and checkstyle static analysis" />
310 <target name="checkstyle" />
311 <target name="test" depends="build" />
312 <target name="build" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000313
fabbott@google.com71e72af2009-06-13 02:28:21 +0000314 <target name="clean">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000315 <delete dir="${project.build}" />
316 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000317
318</project>