forked from mit-cml/appinventor-sources
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-common.xml
363 lines (315 loc) · 15.9 KB
/
build-common.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
<?xml version="1.0"?>
<!-- ======================================================================
Copyright 2011 Google Inc. All Rights Reserved.
Copyright 2012-2017 MIT. All Rights Reserved.
Author: lizlooney@google.com (Liz Looney)
Author: andrew.f.mckinney@gmail.com (Andrew F. McKinney)
Author: ewpatton@mit.edu (Evan W. Patton)
Author: jis@mit.edu (Jeffrey I. Schiller)
Author: ram8647@gmail.com (Ralph Morelli)
Author: sharon@google.com (Sharon Perl)
Author: trevorbadams@gmail.com (Treavor Adams)
Contains definitions common to multiple App Inventor build.xml files.
====================================================================== -->
<project name="CommonDefinitions" xmlns:if="ant:if" xmlns:unless="ant:unless">
<!-- Always build with debug set... (jis) -->
<property name="debug" value="true"/>
<description>
Definitions common to multiple App Inventor build.xml files."
</description>
<!-- =====================================================================
Define output directories.
===================================================================== -->
<!-- appinventor.dir is the root directory of the appinventor world -->
<dirname property="appinventor.dir" file="${ant.file.CommonDefinitions}" />
<!-- build.dir is the grandparent directory for output files that were
created by another project. This directory is the same for each project.
For example, if a project needs CommonUtils.jar, which is built by the
common project, the ai.javac
task's classpath would include this entry:
<pathelement location="${build.dir}/common/CommonUtils.jar"/>
-->
<property name="build.dir" location="${appinventor.dir}/build" />
<!-- public.build.dir is the directory for output files that will be used
by another project. This directory is different for each project. For
example, when the common project builds CommonUtils.jar, which is used by
the appengine project, the jar task's destFile attribute looks like this:
<jar destfile="${public.build.dir}/CommonUtils.jar">
-->
<property name="public.build.dir" location="${build.dir}/${ant.project.name}" />
<!-- local.build.dir is the directory for output files that will not be used
by another project. This directory is different for each project. For
example, when the components project builds AnnotationProcessors.jar,
which is not used by any other project, the jar tasks's destFile
attribute looks like this:
<jar destfile="${local.build.dir}/AnnotationProcessors.jar"
-->
<property name="local.build.dir" location="${basedir}/build" />
<!-- class.dir is the directory for class files created by javac. This
directory is different for each project. Most projects create a separate
subdirectory for each target that produces class files. For example,
when the common project builds CommonUtils, the ai.javac task's destdir
attribute looks like this:
<property name="CommonUtils-class.dir" location="${class.dir}/CommonUtils" />
<mkdir dir="${CommonUtils-class.dir}" />
<ai.javac destdir="${CommonUtils-class.dir}">
-->
<property name="class.dir" location="${local.build.dir}/classes" />
<!-- reports.dir is the directory for testing reports created by junitreport. This
directory is different for each project.
-->
<property name="reports.dir" location="${basedir}/reports"/>
<!-- =====================================================================
Define src.dir and tests.dir relative to the including file's base directory.
===================================================================== -->
<property name="src.dir" location="${basedir}/src" />
<property name="tests.dir" location="${basedir}/tests" />
<!-- Determine the source/target Java version -->
<condition property="lang.version" value="8" else="${java.specification.version}">
<matches pattern="1.\d+" string="${java.specification.version}" />
</condition>
<!-- ====================================================================
Pull in definition of propertyregex task from Ant Contrib jar
===================================================================== -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${appinventor.dir}/lib/ant-contrib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- =====================================================================
Define task ai.javac as the default compilation task for AI. It sets
includeantruntime to false to override broken default behavior
(http://goo.gl/XM29h), and it sets srcdir and sourcepath.
Invocations of the task must specify includes. If -Ddebug=true is
specified on the command line, debug compilation will be done with
debuglevel="lines,vars,source".
===================================================================== -->
<!-- sets debug.compile to true if -Ddebug=true is specified on the command
line and false otherwise -->
<condition property="debug.compile" else="false">
<isset property="debug" />
</condition>
<macrodef name="ai.javac">
<attribute name="srcdir" default="${src.dir}"/>
<attribute name="destdir"/>
<attribute name="encoding" default="utf-8"/>
<attribute name="nowarn" default="off"/>
<attribute name="source" default="${lang.version}"/>
<attribute name="target" default="${lang.version}"/>
<attribute name="deprecation" default="off"/>
<attribute name="debug" default="${debug.compile}"/>
<attribute name="debuglevel" default="lines,vars,source"/>
<element name="implicit-elements" implicit="yes"/>
<sequential>
<depend srcdir="@{srcdir}"
destdir="@{destdir}">
<implicit-elements/>
</depend>
<javac sourcepath=""
srcdir="@{srcdir}"
destdir="@{destdir}"
includeantruntime="false"
encoding="@{encoding}"
source="@{source}"
target="@{target}"
deprecation="@{deprecation}"
nowarn="@{nowarn}"
debug="@{debug}"
debuglevel="@{debuglevel}">
<implicit-elements/>
</javac>
</sequential>
</macrodef>
<!-- =====================================================================
Define task ai.javactests as the compilation task for building the
test classes. The test classes include debug information so we can
see the line numbers of test failures.
===================================================================== -->
<presetdef name="ai.javactests">
<ai.javac srcdir="${tests.dir}"
debug="true"/>
</presetdef>
<!-- =====================================================================
Define task ai.dojunit as the default testing task for AI. It
compiles all the specified tests, builds them into a library,
runs them with junit, and then generates a report. It sets
haltonfailure to no so that the tests will continue to run even
after a failure, and so that a report will be generated.
Depends on having the following properties and paths defined:
aij-testingtarget: the name of the target that uses this
macro. It is assumed that there will be a path set with the
name of libsFor${aij-testingtarget}.path which represents
which libaries are needed to compile the tests, and one called
${aij-testingtarget}.path as the libraries needed to run the
tests.
aij-dir: the package and subdirectory containing the tests,
e.g. ${appinventor.pkg}/server
tests.dir (automatically set by this file)
This macro compiles and runs all the specified tests by default, but it also
supports compiling and running a single test. Just specify the test name on the
command line like this:
ant -Dtest_name=com.google.appinventor.common.utils.StringUtilsTest CommonUtilsTests
=====================================================================
-->
<macrodef name="ai.dojunit">
<attribute name="aij-testingtarget" />
<attribute name="aij-dir" />
<attribute name="aij-forkmode" default="once" />
<attribute name="aij-prod" default="false" />
<!-- The following element is used to workaround a bug in older JDKs that prevents
Robolectric's annotations from being read by javac -->
<element name="aij-supplemental-includes" optional="true" />
<sequential>
<local name="classdir" />
<property name="classdir" location="${class.dir}/@{aij-testingtarget}" />
<mkdir dir="${classdir}" />
<!-- if the user specified a particular test name, set the property test_name.class
to its last component -->
<propertyregex property="test_name.class"
input="${test_name}"
regexp="(.*\.)*(.*)"
select="\2" />
<ai.javactests destdir="${classdir}" >
<include name="@{aij-dir}/**/*.java" />
<aij-supplemental-includes />
<classpath refid="libsFor@{aij-testingtarget}.path"/>
</ai.javactests>
<!-- Copy test resources -->
<copy todir="${classdir}">
<fileset dir="${tests.dir}">
<include name="@{aij-dir}/**/*" />
<exclude name="@{aij-dir}/**/*.java" />
</fileset>
</copy>
<jar basedir="${classdir}"
destfile="${local.build.dir}/@{aij-testingtarget}.jar" />
<junit printsummary="yes"
fork="true"
dir="${basedir}"
forkmode="@{aij-forkmode}"
haltonfailure="no"
maxmemory="2000m"
showoutput="no">
<sysproperty key="gwt.args" value="-prod -gen ${local.build.dir}/gen -war ${local.build.dir}/build/war" if:true="@{aij-prod}"/>
<sysproperty key="gwt.args" value="-devMode -logLevel WARN -war ${local.build.dir}/build/war" unless:true="@{aij-prod}"/>
<sysproperty key="java.awt.headless" value="true"/>
<sysproperty key="robolectric.offline" value="true"/>
<sysproperty key="robolectric.dependency.dir" value="${lib.dir}/robolectric" />
<classpath refid="@{aij-testingtarget}.path"/>
<formatter type="xml"/>
<!-- If the ant command line sets the test_name property (see above)
then we just run that one test. -->
<test name="${test_name}" todir="${reports.dir}/raw/" if="test_name"/>
<!-- otherwise, we run all the tests -->
<batchtest todir="${reports.dir}/raw/" unless="test_name">
<fileset dir="${tests.dir}">
<include name="@{aij-dir}/**/*Test.java" />
<exclude name="@{aij-dir}/**/Abstract*Test.java" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${reports.dir}">
<fileset dir="${reports.dir}/raw/">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${reports.dir}/html"/>
</junitreport>
<echo message="Please see the report at file://${reports.dir}/html/index.html"/>
</sequential>
</macrodef>
<!-- ====================================================================
Define property for external libraries directory.
==================================================================== -->
<property name="lib.dir" location="${appinventor.dir}/lib" />
<!-- ====================================================================
Define property for docs directory.
==================================================================== -->
<property name="docs.dir" location="${appinventor.dir}/docs" />
<!-- =====================================================================
Add the animal sniffer ant tasks
===================================================================== -->
<typedef uri="antlib:org.codehaus.mojo.animal_sniffer">
<classpath path="${lib.dir}/animal_sniffer/animal-sniffer-ant-tasks-1.7.jar"/>
</typedef>
<!-- ====================================================================
Define standard targets.
==================================================================== -->
<!-- clean -->
<target name="clean"
description="Remove generated directories and files for the specific project">
<delete dir="${public.build.dir}" />
<delete dir="${local.build.dir}" />
<delete dir="${class.dir}" />
<delete dir="${reports.dir}" />
</target>
<!-- init -->
<target name="init"
description="Create required output directories">
<mkdir dir="${public.build.dir}" />
<mkdir dir="${local.build.dir}" />
<mkdir dir="${class.dir}" />
<mkdir dir="${reports.dir}" />
<mkdir dir="${reports.dir}/raw/"/>
<mkdir dir="${reports.dir}/html/"/>
</target>
<!-- targets that build dependencies -->
<!-- ====================================================================
blocklyeditor_BlocklyCompile builds:
- build/blockly-all.js
==================================================================== -->
<target name="blocklyeditor_BlocklyCompile">
<ant inheritAll="false" useNativeBasedir="true" dir="${appinventor.dir}/blocklyeditor"
target="BlocklyCompile"/>
</target>
<!-- ====================================================================
blocklyeditor_BlocklyCompile builds:
- build/blockly-all.js
==================================================================== -->
<target name="blocklyeditor_BlocklyTranslationGenerator">
<ant inheritall="false" usenativebasedir="true" dir="${appinventor.dir}/blocklyeditor"
target="BlocklyTranslationGenerator"/>
</target>
<!-- ====================================================================
common_CommonUtils builds:
- build/common/CommonUtils.jar
- build/common/CommonUtils-gwt.jar
==================================================================== -->
<target name="common_CommonUtils">
<ant inheritAll="false" useNativeBasedir="true" dir="${appinventor.dir}/common"
target="CommonUtils"/>
</target>
<!-- ====================================================================
common_CommonVersion builds:
- build/common/CommonVersion.jar
- build/common/CommonVersion-gwt.jar
==================================================================== -->
<target name="common_CommonVersion">
<ant inheritAll="false" useNativeBasedir="true" dir="${appinventor.dir}/common"
target="CommonVersion"/>
</target>
<!-- ====================================================================
common_CommonTestUtils builds:
- build/common/CommonTestUtils.jar
==================================================================== -->
<target name="common_CommonTestUtils">
<ant inheritAll="false" useNativeBasedir="true" dir="${appinventor.dir}/common"
target="CommonTestUtils"/>
</target>
<!-- ====================================================================
components_AndroidRuntime builds:
- build/components/AndroidRuntime.jar
==================================================================== -->
<target name="components_AndroidRuntime">
<ant inheritAll="false" useNativeBasedir="true" dir="${appinventor.dir}/components"
target="AndroidRuntime"/>
</target>
<!-- ====================================================================
components_CommonConstants builds:
- build/components/CommonConstants.jar
- build/components/CommonConstants-gwt.jar
==================================================================== -->
<target name="components_CommonConstants">
<ant inheritAll="false" useNativeBasedir="true" dir="${appinventor.dir}/components"
target="CommonConstants"/>
</target>
</project>