blob: 2e2c78a60086e30f6c2fd777c71bedd871a88c1a [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" />
bobv@google.comb2bd3f52009-02-19 23:38:40 +000040 <property name="gwt.threadsPerProcessor" value="1" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000041 <property name="project.build" location="${gwt.build.out}/${project.tail}" />
42 <property name="project.lib" location="${gwt.build.lib}/gwt-${ant.project.name}.jar" />
43 <property name="project.jni" location="${gwt.build}/${project.tail}" />
44 <property name="javac.out" location="${project.build}/bin" />
45 <property name="javac.junit.out" location="${project.build}/bin-test" />
46 <property name="javac.debug" value="true" />
47 <property name="javac.debuglevel" value="lines,vars,source" />
48 <property name="javac.encoding" value="utf-8" />
49 <property name="javac.source" value="1.5" />
50 <property name="javac.target" value="1.5" />
51 <property name="javac.nowarn" value="true" />
52 <property name="junit.out" location="${project.build}/test" />
53
54 <!-- Sanity check -->
55 <available file="${gwt.tools}" type="dir" property="gwt.tools.exists" />
56 <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 +000057
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000058 <!-- Platform identification -->
59 <condition property="build.host.islinux">
60 <and>
61 <os family="unix" />
62 <not>
63 <contains string="${os.name}" substring="mac" casesensitive="false" />
64 </not>
65 </and>
66 </condition>
67 <condition property="build.host.platform" value="linux">
68 <isset property="build.host.islinux" />
69 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000070
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000071 <condition property="build.host.ismac">
72 <and>
73 <os family="unix" />
74 <contains string="${os.name}" substring="mac" casesensitive="false" />
75 </and>
76 </condition>
77 <condition property="build.host.platform" value="mac">
78 <isset property="build.host.ismac" />
79 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000080
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000081 <condition property="build.host.iswindows">
82 <os family="windows" />
83 </condition>
84 <condition property="build.host.platform" value="windows">
85 <isset property="build.host.iswindows" />
86 </condition>
87 <fail unless="build.host.platform" message="Building on ${os.name} is not supported" />
gwt.team.scottb193a3b92006-12-11 22:24:38 +000088
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000089 <condition property="junit.platform.args" value="-XstartOnFirstThread" else="">
90 <isset property="build.host.ismac" />
91 </condition>
gwt.team.scottb193a3b92006-12-11 22:24:38 +000092
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000093 <!-- JUnit support -->
94 <property name="gwt.dev.staging.jar" location="${gwt.build.staging}/gwt-${build.host.platform}-${gwt.version}/gwt-dev-${build.host.platform}.jar" />
95 <property name="gwt.junit.port" value="8888" />
96 <property name="gwt.junit.testcase.includes" value="**/*Suite.class"/>
gwt.team.zundel910448e2008-04-26 13:56:28 +000097
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000098 <!-- Headless mode keeps the hosted mode browser and log window
99 from popping up during a unit test run. This is usually desirable,
100 but the WebKit layout engine performs some optimizations in
101 headless mode that causes some GWT unit tests to break. The
102 solution for the time being is to turn off headless mode on
103 the mac.
104 -->
105 <condition property="junit.headless">
106 <not>
107 <isset property="build.host.ismac" />
108 </not>
109 </condition>
110 <condition property="junit.notheadless.arg" value="-notHeadless" else="">
111 <not>
112 <isset property="junit.headless" />
113 </not>
114 </condition>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000115
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000116 <!-- Pulls in tasks defined in ant-contrib, i.e. foreach -->
117 <taskdef resource="net/sf/antcontrib/antlib.xml">
118 <classpath>
119 <pathelement location="${gwt.tools.antlib}/ant-contrib-1.0b3.jar" />
120 </classpath>
121 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000122
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000123 <!-- Global Custom Tasks -->
124 <presetdef name="gwt.ant">
125 <ant inheritall="false" target="${target}">
126 <propertyset>
127 <propertyref name="gwt.version" />
128 <propertyref name="gwt.junit.port" />
129 <propertyref name="gwt.remote.browsers" />
130 </propertyset>
131 </ant>
132 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000133
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000134 <presetdef name="gwt.javac">
135 <javac srcdir="src" destdir="${javac.out}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.source}" target="${javac.target}" nowarn="${javac.nowarn}" encoding="${javac.encoding}" />
136 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000137
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000138 <presetdef name="gwt.jar">
139 <jar destfile="${project.lib}" update="true" duplicate="preserve" index="true" />
140 </presetdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000141
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000142 <macrodef name="gwt.junit">
143 <!-- TODO: make this more generic / refactor so it can be used from dev/core -->
144 <attribute name="test.args" default="" />
145 <attribute name="test.out" default="" />
146 <attribute name="test.reports" default="@{test.out}/reports" />
147 <attribute name="test.cases" default="" />
148 <element name="extraclasspaths" optional="true" />
149 <sequential>
150 <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
151 <classpath>
152 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
153 <pathelement location="${gwt.tools.antlib}/ant-junit-1.6.5.jar" />
154 <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
155 </classpath>
156 </taskdef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000157
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000158 <echo message="Writing test results to @{test.reports} for @{test.cases}" />
159 <mkdir dir="@{test.reports}" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000160
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000161 <echo message="${javac.out} ${javac.junit.out}" />
162 <junit dir="@{test.out}" fork="yes" printsummary="yes" failureproperty="junit.failure" >
163 <jvmarg line="${junit.platform.args}" />
164 <jvmarg line="-Xmx512m" />
165 <sysproperty key="gwt.args" value="${junit.notheadless.arg} @{test.args}" />
166 <sysproperty key="java.awt.headless" value="${junit.headless}" />
167 <sysproperty key="gwt.devjar" value="${gwt.dev.staging.jar}" />
168 <classpath>
169 <pathelement location="${gwt.root}/${project.tail}/src" />
170 <pathelement location="${gwt.root}/${project.tail}/super" />
171 <pathelement location="${gwt.root}/${project.tail}/test" />
172 <pathelement location="${javac.junit.out}" />
173 <pathelement location="${javac.out}" />
174 <pathelement location="${gwt.dev.staging.jar}" />
175 <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
176 <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />
177 <extraclasspaths />
178 </classpath>
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000179
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000180 <formatter type="plain" />
181 <formatter type="xml" />
gwt.team.mmendez99f280b2006-12-08 23:11:29 +0000182
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000183 <batchtest todir="@{test.reports}">
184 <fileset refid="@{test.cases}" />
185 </batchtest>
186 </junit>
187 <fail message="One or more junit tests failed" if="junit.failure" />
188 </sequential>
189 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000190
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000191 <macrodef name="gwt.tgz.cat">
192 <attribute name="destfile" />
193 <attribute name="compression" default="gzip" />
194 <element name="tar.elements" implicit="true" optional="true" />
195 <sequential>
196 <taskdef name="tar.cat" classname="com.google.gwt.ant.taskdefs.TarCat" classpath="${gwt.build.lib}/ant-gwt.jar" />
197 <tar.cat destfile="@{destfile}" compression="@{compression}" longfile="gnu">
198 <tar.elements />
199 </tar.cat>
200 </sequential>
201 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000202
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000203 <macrodef name="gwt.getsvninfo" description="Identifies the SVN info of a workspace">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000204 <sequential>
fabbott@google.com66b79062008-09-20 05:44:47 +0000205 <taskdef name="svninfo"
206 classname="com.google.gwt.ant.taskdefs.SvnInfo"
207 classpath="${gwt.build.lib}/ant-gwt.jar" />
fabbott@google.com4e4f3632008-09-23 01:15:55 +0000208 <svninfo directory="${gwt.root}" outputproperty="gwt.svnrev"
fabbott@google.com66b79062008-09-20 05:44:47 +0000209 outputfileproperty="gwt.svnrev.filename" />
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000210 <!-- Generally, filtering requires a sentinel file so that changes to svn rev will
211 be noticed as invalidating the previously-generated filter output. This property
212 names where such a sentinel lives; it is tested with <available/> and created
213 with <touch/> -->
214 <mkdir dir="${project.build}/sentinels" />
215 <property name="filter.sentinel"
216 location="${project.build}/sentinels/gwt-${gwt.version}-svn-${gwt.svnrev.filename}" />
217 </sequential>
218 </macrodef>
219
220 <macrodef name="gwt.revfilter" description="Filters files for versioning">
221 <attribute name="todir" description="Destination for the filtered copy"/>
222
223 <element name="src.fileset" implicit="true"
224 description="Source for the filtered copy"/>
225 <sequential>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000226 <!-- These files must be filtered for versioning -->
fabbott@google.com3b1edcc2008-09-11 03:19:19 +0000227 <echo message="Branding as GWT version ${gwt.version}, SVN rev ${gwt.svnrev}"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000228 <mkdir dir="@{todir}" />
229 <copy todir="@{todir}" overwrite="true">
230 <src.fileset/>
231 <filterset>
232 <filter token="GWT_VERSION" value="${gwt.version}" />
233 <filter token="GWT_SVNREV" value="${gwt.svnrev}" />
234 </filterset>
235 </copy>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000236 </sequential>
237 </macrodef>
fabbott@google.com4a87ea12008-08-20 21:02:23 +0000238
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000239 <macrodef name="gwt.timer">
240 <attribute name="name"/>
241 <element name="timer.elements" implicit="true" optional="false"/>
242 <sequential>
243 <taskdef name="timer"
244 classname="com.google.gwt.ant.taskdefs.Timer"
245 classpath="${gwt.build.lib}/ant-gwt.jar" />
246 <timer name="@{name}">
247 <timer.elements/>
248 </timer>
249 </sequential>
250 </macrodef>
fabbott@google.comf8284cd2008-05-09 20:14:51 +0000251
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000252 <macrodef name="gwt.checkstyle">
253 <element name="sourcepath" implicit="yes" optional="true" />
254 <sequential>
255 <taskdef resource="checkstyletask.properties" classpath="${gwt.tools.antlib}/checkstyle-all-4.2.jar;${gwt.build.lib}/gwt-customchecks.jar" />
jgw@google.coma3509e22009-02-06 21:06:24 +0000256 <checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle.xml" maxErrors="0">
257 <formatter type="xml" toFile="${project.build}/checkstyle_log.xml"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000258 <property key="checkstyle.header.file" file="${gwt.root}/eclipse/settings/code-style/google.header" />
259 <sourcepath />
260 </checkstyle>
jgw@google.coma3509e22009-02-06 21:06:24 +0000261 <echo message="Checkstyle messages are reported in checkstyle_log.xml located at ${project.build}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000262 </sequential>
263 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000264
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000265 <macrodef name="property.ensure">
266 <attribute name="name" />
267 <attribute name="location" />
268 <attribute name="message" default="Cannot find dependency ${@{name}}" />
269 <attribute name="unless" default="__nonexistent_property__" />
270 <sequential>
271 <property name="@{name}" location="@{location}" />
272 <condition property="@{name}.exists">
273 <or>
274 <available file="${@{name}}" />
275 <isset property="@{unless}" />
276 </or>
277 </condition>
278 <fail unless="@{name}.exists" message="@{message}" />
279 </sequential>
280 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000281
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000282 <!-- Default implementations of the required targets; projects should
283 override the ones that matter -->
284 <target name="all" depends="verify" />
285 <target name="verify" depends="checkstyle, test" description="Verify this project" />
286 <target name="checkstyle" description="Static analysis of source" />
287 <target name="test" depends="build" description="Test this project" />
288 <target name="build" description="Build and (maybe) package this project" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000289
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000290 <target name="clean" description="Cleans this project's intermediate and output files">
291 <delete dir="${project.build}" />
292 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000293
294</project>