blob: 1bbd0e192ae3520963aba2c2ce1e2ca0ceb86eda [file] [log] [blame]
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +00001<project name="common">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +00002 <!-- gwt.build.iscasesensitivefs is true if the filesystem of the
3 build machine is case-sensitive, false otherwise. Update with
4 new lines for any supported platforms with case-insensitive
5 filesystems
6 -->
7 <condition property="gwt.build.iscasesensitivefs" else="false">
8 <not>
9 <or>
10 <os family="windows"/>
11 </or>
12 </not>
13 </condition>
gwt.team.jatceab1ec2006-12-28 22:48:49 +000014
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000015 <property name="test.ant.file" location="${gwt.root}/${project.tail}/build.xml" />
16 <condition property="project.valid">
17 <equals arg1="${ant.file}" arg2="${test.ant.file}"
18 casesensitive="${gwt.build.iscasesensitivefs}"/>
19 </condition>
20 <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 +000021
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000022 <!-- Global Properties -->
23 <property environment="env" />
24 <condition property="gwt.version" value="${env.GWT_VERSION}" else="0.0.0">
25 <isset property="env.GWT_VERSION" />
26 </condition>
27 <condition property="gwt.tools.check" value="${env.GWT_TOOLS}" else="${gwt.root}/../tools">
28 <isset property="env.GWT_TOOLS" />
29 </condition>
30 <property name="gwt.tools" location="${gwt.tools.check}" />
31 <property name="gwt.tools.lib" location="${gwt.tools}/lib" />
32 <property name="gwt.tools.antlib" location="${gwt.tools}/antlib" />
33 <property name="gwt.tools.redist" location="${gwt.tools}/redist" />
34 <property name="gwt.build" location="${gwt.root}/build" />
35 <property name="gwt.build.out" location="${gwt.build}/out" />
36 <property name="gwt.build.lib" location="${gwt.build}/lib" />
37 <property name="gwt.build.jni" location="${gwt.build}/jni" />
38 <property name="gwt.build.staging" location="${gwt.build}/staging" />
39 <property name="gwt.build.dist" location="${gwt.build}/dist" />
40 <property name="project.build" location="${gwt.build.out}/${project.tail}" />
41 <property name="project.lib" location="${gwt.build.lib}/gwt-${ant.project.name}.jar" />
42 <property name="project.jni" location="${gwt.build}/${project.tail}" />
43 <property name="javac.out" location="${project.build}/bin" />
44 <property name="javac.junit.out" location="${project.build}/bin-test" />
45 <property name="javac.debug" value="true" />
46 <property name="javac.debuglevel" value="lines,vars,source" />
47 <property name="javac.encoding" value="utf-8" />
48 <property name="javac.source" value="1.5" />
49 <property name="javac.target" value="1.5" />
50 <property name="javac.nowarn" value="true" />
51 <property name="junit.out" location="${project.build}/test" />
52
53 <!-- Sanity check -->
54 <available file="${gwt.tools}" type="dir" property="gwt.tools.exists" />
55 <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 +000056
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000057 <!-- Platform identification -->
58 <condition property="build.host.islinux">
59 <and>
60 <os family="unix" />
61 <not>
62 <contains string="${os.name}" substring="mac" casesensitive="false" />
63 </not>
64 </and>
65 </condition>
66 <condition property="build.host.platform" value="linux">
67 <isset property="build.host.islinux" />
68 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000069
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000070 <condition property="build.host.ismac">
71 <and>
72 <os family="unix" />
73 <contains string="${os.name}" substring="mac" casesensitive="false" />
74 </and>
75 </condition>
76 <condition property="build.host.platform" value="mac">
77 <isset property="build.host.ismac" />
78 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000079
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000080 <condition property="build.host.iswindows">
81 <os family="windows" />
82 </condition>
83 <condition property="build.host.platform" value="windows">
84 <isset property="build.host.iswindows" />
85 </condition>
86 <fail unless="build.host.platform" message="Building on ${os.name} is not supported" />
gwt.team.scottb193a3b92006-12-11 22:24:38 +000087
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000088 <condition property="junit.platform.args" value="-XstartOnFirstThread" else="">
89 <isset property="build.host.ismac" />
90 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000091
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000092 <!-- JUnit support -->
93 <property name="gwt.dev.staging.jar" location="${gwt.build.staging}/gwt-${build.host.platform}-${gwt.version}/gwt-dev-${build.host.platform}.jar" />
94 <property name="gwt.junit.port" value="8888" />
95 <property name="gwt.junit.testcase.includes" value="**/*Suite.class"/>
gwt.team.zundel910448e2008-04-26 13:56:28 +000096
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000097 <!-- Headless mode keeps the hosted mode browser and log window
98 from popping up during a unit test run. This is usually desirable,
99 but the WebKit layout engine performs some optimizations in
100 headless mode that causes some GWT unit tests to break. The
101 solution for the time being is to turn off headless mode on
102 the mac.
103 -->
104 <condition property="junit.headless">
105 <not>
106 <isset property="build.host.ismac" />
107 </not>
108 </condition>
109 <condition property="junit.notheadless.arg" value="-notHeadless" else="">
110 <not>
111 <isset property="junit.headless" />
112 </not>
113 </condition>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000114
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000115 <!-- Pulls in tasks defined in ant-contrib, i.e. foreach -->
116 <taskdef resource="net/sf/antcontrib/antlib.xml">
117 <classpath>
118 <pathelement location="${gwt.tools.antlib}/ant-contrib-1.0b3.jar" />
119 </classpath>
120 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000121
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000122 <!-- Global Custom Tasks -->
123 <presetdef name="gwt.ant">
124 <ant inheritall="false" target="${target}">
125 <propertyset>
126 <propertyref name="gwt.version" />
127 <propertyref name="gwt.junit.port" />
128 <propertyref name="gwt.remote.browsers" />
129 </propertyset>
130 </ant>
131 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000132
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000133 <presetdef name="gwt.javac">
134 <javac srcdir="src" destdir="${javac.out}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.source}" target="${javac.target}" nowarn="${javac.nowarn}" encoding="${javac.encoding}" />
135 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000136
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000137 <presetdef name="gwt.jar">
138 <jar destfile="${project.lib}" update="true" duplicate="preserve" index="true" />
139 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000140
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000141 <macrodef name="gwt.junit">
142 <!-- TODO: make this more generic / refactor so it can be used from dev/core -->
143 <attribute name="test.args" default="" />
144 <attribute name="test.out" default="" />
145 <attribute name="test.reports" default="@{test.out}/reports" />
146 <attribute name="test.cases" default="" />
147 <element name="extraclasspaths" optional="true" />
148 <sequential>
149 <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
150 <classpath>
151 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
152 <pathelement location="${gwt.tools.antlib}/ant-junit-1.6.5.jar" />
153 <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
154 </classpath>
155 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000156
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000157 <echo message="Writing test results to @{test.reports} for @{test.cases}" />
158 <mkdir dir="@{test.reports}" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000159
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000160 <echo message="${javac.out} ${javac.junit.out}" />
161 <junit dir="@{test.out}" fork="yes" printsummary="yes" failureproperty="junit.failure" >
162 <jvmarg line="${junit.platform.args}" />
163 <jvmarg line="-Xmx512m" />
164 <sysproperty key="gwt.args" value="${junit.notheadless.arg} @{test.args}" />
165 <sysproperty key="java.awt.headless" value="${junit.headless}" />
166 <sysproperty key="gwt.devjar" value="${gwt.dev.staging.jar}" />
167 <classpath>
168 <pathelement location="${gwt.root}/${project.tail}/src" />
169 <pathelement location="${gwt.root}/${project.tail}/super" />
170 <pathelement location="${gwt.root}/${project.tail}/test" />
171 <pathelement location="${javac.junit.out}" />
172 <pathelement location="${javac.out}" />
173 <pathelement location="${gwt.dev.staging.jar}" />
174 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
175 <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
176 <extraclasspaths />
177 </classpath>
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000178
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000179 <formatter type="plain" />
180 <formatter type="xml" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000181
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000182 <batchtest todir="@{test.reports}">
183 <fileset refid="@{test.cases}" />
184 </batchtest>
185 </junit>
186 <fail message="One or more junit tests failed" if="junit.failure" />
187 </sequential>
188 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000189
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000190 <macrodef name="gwt.tgz.cat">
191 <attribute name="destfile" />
192 <attribute name="compression" default="gzip" />
193 <element name="tar.elements" implicit="true" optional="true" />
194 <sequential>
195 <taskdef name="tar.cat" classname="com.google.gwt.ant.taskdefs.TarCat" classpath="${gwt.build.lib}/ant-gwt.jar" />
196 <tar.cat destfile="@{destfile}" compression="@{compression}" longfile="gnu">
197 <tar.elements />
198 </tar.cat>
199 </sequential>
200 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000201
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000202 <macrodef name="gwt.getsvninfo" description="Identifies the SVN info of a workspace">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000203 <sequential>
fabbott@google.com66b79062008-09-20 05:44:47 +0000204 <taskdef name="svninfo"
205 classname="com.google.gwt.ant.taskdefs.SvnInfo"
206 classpath="${gwt.build.lib}/ant-gwt.jar" />
fabbott@google.com4e4f3632008-09-23 01:15:55 +0000207 <svninfo directory="${gwt.root}" outputproperty="gwt.svnrev"
fabbott@google.com66b79062008-09-20 05:44:47 +0000208 outputfileproperty="gwt.svnrev.filename" />
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000209 <!-- Generally, filtering requires a sentinel file so that changes to svn rev will
210 be noticed as invalidating the previously-generated filter output. This property
211 names where such a sentinel lives; it is tested with <available/> and created
212 with <touch/> -->
213 <mkdir dir="${project.build}/sentinels" />
214 <property name="filter.sentinel"
215 location="${project.build}/sentinels/gwt-${gwt.version}-svn-${gwt.svnrev.filename}" />
216 </sequential>
217 </macrodef>
218
219 <macrodef name="gwt.revfilter" description="Filters files for versioning">
220 <attribute name="todir" description="Destination for the filtered copy"/>
221
222 <element name="src.fileset" implicit="true"
223 description="Source for the filtered copy"/>
224 <sequential>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000225 <!-- These files must be filtered for versioning -->
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000226 <echo message="Branding as GWT version ${gwt.version}, SVN rev ${gwt.svnrev}"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000227 <mkdir dir="@{todir}" />
228 <copy todir="@{todir}" overwrite="true">
229 <src.fileset/>
230 <filterset>
231 <filter token="GWT_VERSION" value="${gwt.version}" />
232 <filter token="GWT_SVNREV" value="${gwt.svnrev}" />
233 </filterset>
234 </copy>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000235 </sequential>
236 </macrodef>
fabbott@google.com4a87ea12008-08-20 21:02:23 +0000237
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000238 <macrodef name="gwt.timer">
239 <attribute name="name"/>
240 <element name="timer.elements" implicit="true" optional="false"/>
241 <sequential>
242 <taskdef name="timer"
243 classname="com.google.gwt.ant.taskdefs.Timer"
244 classpath="${gwt.build.lib}/ant-gwt.jar" />
245 <timer name="@{name}">
246 <timer.elements/>
247 </timer>
248 </sequential>
249 </macrodef>
fabbott@google.comf8284cd2008-05-09 20:14:51 +0000250
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000251 <macrodef name="gwt.checkstyle">
252 <element name="sourcepath" implicit="yes" optional="true" />
253 <sequential>
254 <taskdef resource="checkstyletask.properties" classpath="${gwt.tools.antlib}/checkstyle-all-4.2.jar;${gwt.build.lib}/gwt-customchecks.jar" />
ecc@google.comed46bf82009-01-29 17:07:24 +0000255 <checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle.xml" maxErrors="0">
256 <formatter type="xml" toFile="${project.build}/checkstyle_log.xml"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000257 <property key="checkstyle.header.file" file="${gwt.root}/eclipse/settings/code-style/google.header" />
258 <sourcepath />
259 </checkstyle>
ecc@google.comed46bf82009-01-29 17:07:24 +0000260 <echo message="Checkstyle messages are reported in checkstyle_log.xml located at ${project.build}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000261 </sequential>
262 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000263
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000264 <macrodef name="property.ensure">
265 <attribute name="name" />
266 <attribute name="location" />
267 <attribute name="message" default="Cannot find dependency ${@{name}}" />
268 <attribute name="unless" default="__nonexistent_property__" />
269 <sequential>
270 <property name="@{name}" location="@{location}" />
271 <condition property="@{name}.exists">
272 <or>
273 <available file="${@{name}}" />
274 <isset property="@{unless}" />
275 </or>
276 </condition>
277 <fail unless="@{name}.exists" message="@{message}" />
278 </sequential>
279 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000280
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000281 <!-- Default implementations of the required targets; projects should
282 override the ones that matter -->
283 <target name="all" depends="verify" />
284 <target name="verify" depends="checkstyle, test" description="Verify this project" />
285 <target name="checkstyle" description="Static analysis of source" />
286 <target name="test" depends="build" description="Test this project" />
287 <target name="build" description="Build and (maybe) package this project" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000288
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000289 <target name="clean" description="Cleans this project's intermediate and output files">
290 <delete dir="${project.build}" />
291 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000292
293</project>