forked from WeTheInternet/gwt-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.ant.xml
executable file
·415 lines (375 loc) · 16.9 KB
/
common.ant.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<project name="common">
<!-- it's okay for this not to exist, but it gives a place to store
personal property settings, if any, persistently. For example, you
might use it to set gwt.junit.testcase.includes to a narrower subset
of test cases to exercise. -->
<property file="local.ant.properties"/>
<!-- gwt.build.iscasesensitivefs is true if the filesystem of the
build machine is case-sensitive, false otherwise. Update with
new lines for any supported platforms with case-insensitive
filesystems
-->
<condition property="gwt.build.iscasesensitivefs" else="false">
<not>
<or>
<os family="windows"/>
</or>
</not>
</condition>
<property name="test.ant.file" location="${gwt.root}/${project.tail}/build.xml"/>
<condition property="project.valid">
<equals arg1="${ant.file}" arg2="${test.ant.file}"
casesensitive="${gwt.build.iscasesensitivefs}"/>
</condition>
<fail unless="project.valid"
message="This build file is in an inconsistent state (${ant.file} != ${test.ant.file})."/>
<!-- Global Properties -->
<property environment="env"/>
<condition property="gwt.version" value="${env.GWT_VERSION}" else="0.0.0">
<isset property="env.GWT_VERSION"/>
</condition>
<condition property="gwt.tools.check" value="${env.GWT_TOOLS}" else="${gwt.root}/../tools">
<isset property="env.GWT_TOOLS"/>
</condition>
<property name="gwt.tools" location="${gwt.tools.check}"/>
<property name="gwt.tools.lib" location="${gwt.tools}/lib"/>
<property name="gwt.tools.antlib" location="${gwt.tools}/antlib"/>
<property name="gwt.tools.redist" location="${gwt.tools}/redist"/>
<property name="gwt.build" location="${gwt.root}/build"/>
<property name="gwt.build.out" location="${gwt.build}/out"/>
<property name="gwt.build.lib" location="${gwt.build}/lib"/>
<property name="gwt.build.jni" location="${gwt.build}/jni"/>
<property name="gwt.build.staging" location="${gwt.build}/staging"/>
<property name="gwt.build.dist" location="${gwt.build}/dist"/>
<!-- gwt.threadsPerProcessor supercedes gwt.threadCount unless set to 0 -->
<property name="gwt.threadsPerProcessor" value="1"/>
<property name="gwt.threadCount" value="1"/>
<property name="project.build" location="${gwt.build.out}/${project.tail}"/>
<property name="project.lib" location="${gwt.build.lib}/gwt-${ant.project.name}.jar"/>
<property name="project.jni" location="${gwt.build}/${project.tail}"/>
<property name="javac.out" location="${project.build}/bin"/>
<property name="javac.junit.out" location="${project.build}/bin-test"/>
<property name="javac.emma.out" location="${project.build}/bin-emma"/>
<property name="javac.debug" value="true"/>
<property name="javac.debuglevel" value="lines,vars,source"/>
<property name="javac.encoding" value="utf-8"/>
<property name="javac.source" value="1.7"/>
<property name="javac.target" value="1.7"/>
<property name="javac.nowarn" value="true"/>
<property name="junit.out" location="${project.build}/test"/>
<property name="emma.dir" value="${gwt.tools.redist}/emma"/>
<property name="emma.filter.exclude" value=""/>
<!-- Sanity check -->
<available file="${gwt.tools}" type="dir" property="gwt.tools.exists"/>
<fail unless="gwt.tools.exists"
message="Cannot find '${gwt.tools}' tools directory; perhaps you should define the GWT_TOOLS environment variable"/>
<!-- Platform identification -->
<condition property="build.host.islinux">
<and>
<os family="unix"/>
<not>
<contains string="${os.name}" substring="mac" casesensitive="false"/>
</not>
</and>
</condition>
<condition property="build.host.platform" value="linux">
<isset property="build.host.islinux"/>
</condition>
<condition property="build.host.ismac">
<and>
<os family="unix"/>
<contains string="${os.name}" substring="mac" casesensitive="false"/>
</and>
</condition>
<condition property="build.host.platform" value="mac">
<isset property="build.host.ismac"/>
</condition>
<condition property="build.host.iswindows">
<os family="windows"/>
</condition>
<condition property="build.host.platform" value="windows">
<isset property="build.host.iswindows"/>
</condition>
<fail unless="build.host.platform" message="Building on ${os.name} is not supported"/>
<!-- JVM -->
<condition property="build.jvm.is15">
<equals arg1="${ant.java.version}" arg2="1.5"/>
</condition>
<condition property="build.jvm.is16">
<equals arg1="${ant.java.version}" arg2="1.6"/>
</condition>
<!-- JUnit support -->
<property name="gwt.junit.port" value="8888"/>
<property name="gwt.junit.testcase.includes" value="**/*Suite.class"/>
<!-- Shared class paths -->
<path id="project.classpath.class">
<pathelement location="${javac.out}"/>
</path>
<path id="project.classpath.src">
<pathelement location="${gwt.root}/${project.tail}/src"/>
</path>
<!-- Pulls in tasks defined in ant-contrib, i.e. foreach -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${gwt.tools.antlib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- Pulls in tasks defined in antcount, i.e. countfilter -->
<taskdef resource="net/sf/antcount/antlib.xml">
<classpath>
<pathelement location="${gwt.tools.antlib}/antcount-1.2.jar"/>
</classpath>
</taskdef>
<!-- Global Custom Tasks -->
<presetdef name="gwt.ant">
<ant inheritall="false" target="${target}">
<propertyset>
<propertyref name="gwt.version"/>
<propertyref name="gwt.junit.port"/>
<propertyref name="gwt.remote.browsers"/>
<propertyref name="emma.enabled"/>
<propertyref name="emma.compiled"/>
</propertyset>
</ant>
</presetdef>
<presetdef name="gwt.javac">
<javac srcdir="src" destdir="${javac.out}" debug="${javac.debug}"
debuglevel="${javac.debuglevel}" source="${javac.source}" target="${javac.target}"
nowarn="${javac.nowarn}" encoding="${javac.encoding}" fork="true"
memoryMaximumSize="1024m" includeantruntime="false"/>
</presetdef>
<macrodef name="gwt.jar">
<attribute name="destfile" default="${project.lib}"/>
<attribute name="duplicate" default="preserve"/>
<attribute name="update" default="true"/>
<element name="jarcontents" implicit="true"/>
<sequential>
<jar destfile="@{destfile}" duplicate="@{duplicate}" filesonly="false"
index="true" update="@{update}">
<jarcontents/>
</jar>
</sequential>
</macrodef>
<macrodef name="gwt.junit">
<!-- TODO: Because dev has core, oophm splits, the "common pattern" here doesn't work
for it (and we use extraclasspaths entries instead). Once we lose SWT, we can
consolidate dev/core and dev/oophm, and that can instead more to the normal
pattern. Note also special casing regarding (dev/) core/test. -->
<attribute name="test.args" default=""/>
<attribute name="test.jvmargs" default=""/>
<attribute name="test.out" default=""/>
<attribute name="test.reports" default="@{test.out}/reports"/>
<attribute name="test.emma.coverage" default="@{test.out}/emma-coverage"/>
<attribute name="test.cases" default=""/>
<attribute name="test.name" default=""/>
<attribute name="test.extra.jvmargs" default=""/>
<attribute name="haltonfailure" default="true"/>
<element name="extraclasspaths" optional="true"/>
<sequential>
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
<classpath>
<pathelement location="${gwt.tools.lib}/junit/junit-4.8.2.jar"/>
<pathelement location="${gwt.tools.antlib}/ant-junit-1.6.5.jar"/>
<pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar"/>
</classpath>
</taskdef>
<echo message="Writing test results to @{test.reports} for @{test.cases}"/>
<mkdir dir="@{test.reports}"/>
<antcall target="-create.emma.coverage.if.enabled">
<param name="test.emma.coverage" value="@{test.emma.coverage}"/>
</antcall>
<condition property="emma.lib" value="${emma.dir}/emma-2.0.5312-patched.jar"
else="${emma.dir}/no-emma-requested">
<isset property="emma.enabled"/>
</condition>
<junit dir="@{test.out}" fork="yes" printsummary="yes"
failureproperty="junit.failure" tempdir="@{test.out}">
<jvmarg line="-Xmx1024m"/>
<jvmarg line="-Xss4M"/>
<jvmarg value="-Demma.coverage.out.file=@{test.emma.coverage}/coverage.emma"/>
<jvmarg value="-Demma.coverage.out.merge=true"/>
<jvmarg value="-Dcom.google.gwt.junit.reportPath=reports"/>
<jvmarg line="@{test.jvmargs}"/>
<sysproperty key="gwt.args" value="@{test.args}"/>
<sysproperty key="java.awt.headless" value="true"/>
<classpath>
<path refid="project.classpath.src"/>
<pathelement location="${gwt.root}/${project.tail}/super"/>
<pathelement location="${gwt.root}/${project.tail}/test"/>
<!-- TODO: this is here because e.g. ClassPathEntryTest otherwise fails,
expecting the src entry (core/test) to be earlier than the bin entry
(${javac.junit.out}). -->
<pathelement location="${gwt.root}/${project.tail}/core/test"/>
<!-- Emma compiled classes must appear before non-emma compiled
classes to generate code coverage stats. javac.emma.out is
empty unless emma is enabled. -->
<pathelement location="${javac.emma.out}"/>
<pathelement location="${javac.junit.out}"/>
<path refid="project.classpath.class"/>
<pathelement location="${emma.lib}"/>
<pathelement location="${gwt.dev.staging.jar}"/>
<pathelement location="${gwt.tools.lib}/junit/junit-4.8.2.jar"/>
<pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar"/>
<pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar"/>
<pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3-gg2.jar"/>
<extraclasspaths/>
</classpath>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest todir="@{test.reports}">
<fileset refid="@{test.cases}"/>
</batchtest>
</junit>
<emma enabled="${emma.enabled}">
<report sourcepath="${project.classpath.src}">
<fileset file="${javac.emma.out}/metadata.emma"/>
<fileset dir="@{test.emma.coverage}">
<include name="*.emma"/>
</fileset>
<txt outfile="@{test.emma.coverage}/coverage.txt"/>
<html outfile="@{test.emma.coverage}/coverage.html"/>
<xml outfile="@{test.emma.coverage}/coverage.xml"/>
</report>
</emma>
<condition property="junit.stop.build" value="true">
<and>
<istrue value="@{haltonfailure}"/>
<isset property="junit.failure"/>
</and>
</condition>
<fail
message="One or more junit tests failed for target: @{test.name} @{test.args}"
if="junit.stop.build" status="2"/>
</sequential>
</macrodef>
<macrodef name="gwt.getgitinfo" description="Identifies the GIT info of a workspace">
<sequential>
<exec executable="git" searchpath="true" outputproperty="gwt.gitrev">
<arg line="rev-parse --short HEAD"/>
</exec>
<!-- Generally, filtering requires a sentinel file so that changes to git rev will
be noticed as invalidating the previously-generated filter output. This property
names where such a sentinel lives; it is tested with <available/> and created
with <touch/> -->
<mkdir dir="${project.build}/sentinels"/>
<property name="filter.sentinel"
location="${project.build}/sentinels/gwt-${gwt.version}-git-${gwt.gitrev}"/>
</sequential>
</macrodef>
<macrodef name="gwt.revfilter" description="Filters files for versioning">
<attribute name="todir" description="Destination for the filtered copy"/>
<element name="src.fileset" implicit="true"
description="Source for the filtered copy"/>
<sequential>
<!-- These files must be filtered for versioning -->
<echo message="Branding as GWT version ${gwt.version}, GIT commit ${gwt.gitrev}"/>
<mkdir dir="@{todir}"/>
<copy todir="@{todir}" overwrite="true">
<src.fileset/>
<filterset>
<filter token="GWT_VERSION" value="${gwt.version}"/>
<filter token="GWT_GITREV" value="${gwt.gitrev}"/>
</filterset>
</copy>
</sequential>
</macrodef>
<macrodef name="gwt.checkstyle">
<attribute name="outputdirectory" default="${project.build}"/>
<element name="sourcepath" implicit="yes" optional="true"/>
<sequential>
<taskdef resource="checkstyletask.properties"
classpath="${gwt.tools.antlib}/checkstyle-6.0-all.jar"/>
<mkdir dir="@{outputdirectory}"/>
<checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle.xml" maxErrors="0"
failOnViolation="false" failureProperty="gwt.checkstyle.failed">
<formatter type="xml" toFile="@{outputdirectory}/checkstyle_log.xml"/>
<property key="checkstyle.header.file"
file="${gwt.root}/eclipse/settings/code-style/google.header"/>
<sourcepath/>
</checkstyle>
<fail
message="Checkstyle errors exist, and are reported at @{outputdirectory}/checkstyle_log.xml"
if="gwt.checkstyle.failed"/>
</sequential>
</macrodef>
<macrodef name="gwt.checkstyle.tests">
<attribute name="outputdirectory" default="${project.build}"/>
<element name="sourcepath" implicit="yes" optional="true"/>
<sequential>
<taskdef resource="checkstyletask.properties"
classpath="${gwt.tools.antlib}/checkstyle-6.0-all.jar"/>
<mkdir dir="@{outputdirectory}"/>
<checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle-tests.xml"
maxErrors="0" failOnViolation="false"
failureProperty="gwt.checkstyle-tests.failed">
<formatter type="xml" toFile="@{outputdirectory}/checkstyle_tests_log.xml"/>
<property key="checkstyle.header.file"
file="${gwt.root}/eclipse/settings/code-style/google.header"/>
<sourcepath/>
</checkstyle>
<fail
message="Checkstyle errors exist in tests, and are reported at @{outputdirectory}/checkstyle_tests_log.xml"
if="gwt.checkstyle-tests.failed"/>
</sequential>
</macrodef>
<macrodef name="property.ensure">
<attribute name="name"/>
<attribute name="location"/>
<attribute name="message" default="Cannot find dependency ${@{name}}"/>
<attribute name="unless" default="__nonexistent_property__"/>
<sequential>
<property name="@{name}" location="@{location}"/>
<condition property="@{name}.exists">
<or>
<available file="${@{name}}"/>
<isset property="@{unless}"/>
</or>
</condition>
<fail unless="@{name}.exists" message="@{message}"/>
</sequential>
</macrodef>
<!-- Targets for emma support. To run tests with emma enabled, use
ant <test-target> -Demma.enabled=true -->
<path id="emma.taskdef.lib">
<pathelement location="${emma.dir}/emma-2.0.5312-patched.jar"/>
<pathelement location="${emma.dir}/emma_ant-2.0.5312.jar"/>
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.taskdef.lib"/>
<!-- Instruments emma classes -->
<target name="compile.emma.if.enabled" unless="emma.compiled">
<delete dir="${javac.emma.out}"/>
<property name="emma.compiled" value="true"/>
<antcall target="-compile.emma.if.enabled"/>
</target>
<!-- Instruments emma classes -->
<target name="-compile.emma.if.enabled" if="emma.enabled">
<mkdir dir="${javac.emma.out}"/>
<path id="emma.classpath">
<pathelement location="${javac.out}"/>
</path>
<emma enabled="${emma.enabled}">
<instr instrpathref="emma.classpath" destdir="${javac.emma.out}"
metadatafile="${javac.emma.out}/metadata.emma" merge="false">
<filter includes="com.google.*"/>
<filter excludes="${emma.filter.exclude}"/>
</instr>
</emma>
</target>
<!-- Create the emma coverage directory -->
<target name="-create.emma.coverage.if.enabled" if="emma.enabled">
<delete dir="${test.emma.coverage}"/>
<mkdir dir="${test.emma.coverage}"/>
</target>
<!-- Default implementations of the required targets; projects should
override the ones that matter -->
<target name="all" depends="verify"/>
<target name="verify" depends="checkstyle, test"
description="Runs tests and checkstyle static analysis"/>
<target name="checkstyle"/>
<target name="compile.tests"/>
<target name="test" depends="build"/>
<target name="build"/>
<target name="clean">
<delete dir="${project.build}"/>
</target>
</project>