forked from bolinfest/plovr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
415 lines (370 loc) · 15.4 KB
/
build.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="plovr" basedir="." default="build">
<property file="${basedir}/build.properties" />
<property file="${basedir}/default.build.properties" />
<property name="src.dir" value="${basedir}/src" />
<property name="test.dir" value="${basedir}/test" />
<property name="testdata.dir" value="${basedir}/testdata" />
<property name="www.dir" value="${basedir}/www" />
<property name="demo.dir" value="${www.dir}/demo" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="scripts.dir" value="${basedir}/scripts" />
<property name="build.dir" value="${basedir}/build" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="soy-resources.dir" value="${build.dir}/soy-resources" />
<property name="build.dir.www" value="${build.dir}/www" />
<property name="build.dir.www.jsdoc" value="${build.dir.www}/jsdoc" />
<property name="javadoc.dir" value="${build.dir.www}/javadoc" />
<property name="closure.dir" value="${basedir}/closure" />
<property name="closure-compiler.dir" value="${closure.dir}/closure-compiler" />
<property name="closure-library.dir" value="${closure.dir}/closure-library" />
<property name="closure-stylesheets.dir" value="${closure.dir}/closure-stylesheets" />
<property name="closure-templates.dir" value="${closure.dir}/closure-templates" />
<!--
Use -Dtest.class to change what tests are run on the command-line.
i.e., -Dtest.class=PlovrSoySyntaxExceptionTest will run just that test class.
-->
<property name="test.class" value="*Test"/>
<available file="${build.dir}/plovr.jar"
type="file"
property="jar.present"
/>
<path id="plovr.classpath">
<!-- All jars listed here must also be included in plovr.jar -->
<fileset dir="${lib.dir}" includes="*.jar" />
<fileset dir="${closure-compiler.dir}/lib"
includes="args4j.jar,
guava.jar,
json.jar,
jsr305.jar,
protobuf-java.jar,
truth.jar"
/>
<fileset dir="${closure-templates.dir}/java/lib"
includes="aopalliance.jar,
guice-3.0.jar,
guice-assistedinject-3.0.jar,
guice-multibindings-3.0.jar,
icu4j-51_1.jar,
javax.inject.jar"
/>
<pathelement location="${classes.dir}" />
<!-- Include src.dir to include resources, such as modules.soy -->
<pathelement location="${src.dir}" />
</path>
<target name="clean" description="remove all generated files">
<delete dir="${build.dir}" />
<!-- Clean Closure Templates genfiles. -->
<ant dir="${closure-templates.dir}" target="clean" inheritAll="false" useNativeBasedir="true" />
<!-- No need to clean ${closure-templates.dir}/build or
${closure-compiler.dir}/build because plovr's "compile" target does
not use those directories. It compiles Closure Templates and Closure
Compiler Java files into its own build/classes directory.
-->
</target>
<target name="pre-compile"
description="Closure Tools build steps that must be done before building plovr">
<!-- Build intermediate Closure Templates target for its genfiles. -->
<ant dir="${closure-templates.dir}" target="compile" inheritAll="false" useNativeBasedir="true" />
<ant dir="${closure-stylesheets.dir}" target="javacc" inheritAll="false" useNativeBasedir="true" />
</target>
<target name="compile" depends="pre-compile" description="compile Java source code">
<mkdir dir="${classes.dir}" />
<!--
Compile Closure Stylesheets genfiles separately because it triggers deprecation
warnings, and we would like to compile with warnings treated as errors.
-->
<javac destdir="${classes.dir}"
classpathref="plovr.classpath"
debug="on"
fork="false"
target="1.7"
source="1.7"
includeantruntime="false"
encoding="UTF-8"
>
<compilerarg value="-Werror"/>
<src path="${closure-stylesheets.dir}/src" />
<src path="${closure-stylesheets.dir}/build/genfiles" />
</javac>
<javac destdir="${classes.dir}"
classpathref="plovr.classpath"
debug="on"
deprecation="on"
fork="true"
target="1.7"
source="1.7"
includeantruntime="true"
encoding="UTF-8"
>
<src path="${src.dir}" />
<src path="${test.dir}" />
<src path="${closure-compiler.dir}/src" />
<src path="${closure-compiler.dir}/gen" />
<src path="${closure-templates.dir}/java/src" />
<src path="${closure-templates.dir}/build/genfiles" />
</javac>
<!-- Move Messages.properties where ScriptRuntime.java expects it. -->
<mkdir dir="${classes.dir}/rhino_ast/java/com/google/javascript/rhino/" />
<copy file="${closure-compiler.dir}/src/com/google/javascript/rhino/Messages.properties"
todir="${classes.dir}/rhino_ast/java/com/google/javascript/rhino/" />
<!-- Move ParserConfig.properties where ParserRunner.java expects it. -->
<copy file="${closure-compiler.dir}/src/com/google/javascript/jscomp/parsing/ParserConfig.properties"
todir="${classes.dir}/com/google/javascript/jscomp/parsing" />
<!-- Move compiler JS resources -->
<mkdir dir="${classes.dir}/com/google/javascript/jscomp/js/" />
<copy todir="${classes.dir}/com/google/javascript/jscomp/js">
<fileset dir="${closure-compiler.dir}/src/com/google/javascript/jscomp/js" includes="**/*" />
</copy>
<!-- Copy the JavaScript files from Soy into a directory named "soy". -->
<mkdir dir="${soy-resources.dir}/soy" />
<copy file="${closure-templates.dir}/javascript/soyutils_usegoog.js"
todir="${soy-resources.dir}/soy"
/>
<!-- Copy resources needed for org.plovr package. -->
<copy todir="${classes.dir}/org/plovr">
<fileset dir="${src.dir}/org/plovr">
<include name="**/*.js" />
<include name="**/*.soy" />
</fileset>
</copy>
<!-- Include these files to support the "info" command. -->
<mkdir dir="${classes.dir}/revisions"/>
<copy todir="${basedir}/build/classes/revisions/">
<fileset dir="${basedir}/tools/imports/" includes="rev-*" />
</copy>
<exec executable="bash">
<arg value="${basedir}/insert-plovr-revision.sh" />
</exec>
</target>
<target name="test"
depends="jar"
description="run the unit tests">
<mkdir dir="build/testoutput"/>
<junit failureproperty="hasFailingTests"
showoutput="true">
<formatter type="plain" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="build/testoutput">
<fileset dir="${test.dir}">
<include name="**/${test.class}.java" />
</fileset>
</batchtest>
<classpath refid="plovr.classpath"></classpath>
</junit>
<junitreport todir="build/testoutput">
<fileset dir="build/testoutput" includes="*.xml"/>
<report todir="build/testoutput" />
</junitreport>
<fail if="hasFailingTests" />
<ant dir="${testdata.dir}" target="build" />
</target>
<target name="externs">
<mkdir dir="${classes.dir}" />
<exec executable="bash"
output="${classes.dir}/externs_manifest.txt"
failonerror="true">
<arg value="${basedir}/listfiles.sh" />
<arg value="${closure-compiler.dir}/externs" />
</exec>
<mkdir dir="${classes.dir}/contrib" />
<exec executable="bash"
output="${classes.dir}/contrib_externs.txt"
failonerror="true">
<arg value="${basedir}/tools/externs/listcontrib.sh" />
<arg value="${closure-compiler.dir}/contrib/externs" />
<arg value="${classes.dir}/contrib" />
</exec>
</target>
<target name="library">
<mkdir dir="${classes.dir}" />
<exec executable="bash"
output="${classes.dir}/library_manifest.txt"
failonerror="true">
<arg value="${basedir}/listfiles.sh" />
<arg value="${closure-library.dir}/closure/goog" />
</exec>
</target>
<target name="third_party">
<mkdir dir="${classes.dir}" />
<exec executable="bash"
output="${classes.dir}/third_party_manifest.txt"
failonerror="true">
<arg value="${basedir}/listfiles.sh" />
<arg value="${closure-library.dir}/third_party/closure/goog" />
</exec>
</target>
<target name="jar"
depends="compile, externs, library, third_party"
description="build plovr.jar">
<mkdir dir="${build.dir}" />
<!-- Copy resources needed for org.plovr.docgen package. -->
<copy todir="${classes.dir}/org/plovr/docgen">
<fileset dir="${src.dir}/org/plovr/docgen">
<include name="*.soy" />
<include name="*.css" />
</fileset>
</copy>
<jar destfile="${build.dir}/plovr.jar">
<zipfileset dir="${closure-compiler.dir}/externs/"
includes="**/*.js"
prefix="externs"
/>
<zipfileset dir="${closure-library.dir}/closure/goog/"
includes="**/*.js"
excludes="deps.js"
prefix="closure/goog"
/>
<zipfileset dir="${closure-library.dir}/third_party/closure/goog/"
includes="**/*.js"
excludes="deps.js"
prefix="third_party/closure/goog"
/>
<zipfileset dir="${soy-resources.dir}"
includes="**/*.js"
/>
<zipgroupfileset dir="${lib.dir}"
includes="*.jar"
/>
<zipgroupfileset dir="${closure-compiler.dir}/lib"
includes="args4j.jar,
guava.jar,
json.jar,
jsr305.jar,
protobuf-java.jar"
/>
<zipgroupfileset dir="${closure-templates.dir}/java/lib"
includes="aopalliance.jar,
guice-3.0.jar,
guice-assistedinject-3.0.jar,
guice-multibindings-3.0.jar,
icu4j-51_1.jar,
javax.inject.jar"
/>
<fileset dir="${classes.dir}" />
<manifest>
<attribute name="Main-Class" value="org.plovr.cli.Main" />
</manifest>
</jar>
</target>
<target name="integration-test"
depends="jar"
description="build the jar and run it on localhost:9818">
<echo>Visit http://localhost:9818/compile?id=integration-test</echo>
<java jar="${build.dir}/plovr.jar" fork="true">
<arg value="serve" />
<arg line="--port 9818" />
<arg value="${testdata.dir}/example/integration-test-config.js" />
<arg value="${testdata.dir}/modules/plovr-config.js" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"/>
</java>
</target>
<target name="test-soyweb-server"
description="run the soyweb server in debug mode on localhost:9811">
<echo>Visit http://localhost:9811/hello</echo>
<java jar="${build.dir}/plovr.jar" fork="true">
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"/>
<arg value="soyweb" />
<arg line="--dir ${testdata.dir}/soy-server" />
</java>
</target>
<target name="generate-options-documentation"
description="generate the documentation for ConfigOption.java"
depends="compile">
<mkdir dir="${build.dir.www}" />
<java fork="true"
classname="org.plovr.ConfigOptionDocumentationGenerator"
output="${build.dir.www}/options.html"
failonerror="true"
logerror="true"
>
<classpath refid="plovr.classpath"></classpath>
</java>
</target>
<target name="develop-documentation"
description="run the soyweb server in debug mode to develop docs">
<echo>Visit http://localhost:9811/</echo>
<java jar="${build.dir}/plovr.jar" fork="true">
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"/>
<arg value="soyweb" />
<arg line="--template base" />
<arg line="--dir ${www.dir}" />
<arg line="--globals ${basedir}/www-globals.js" />
</java>
</target>
<target name="javadoc"
description="generate HTML Javadoc for the org.plovr Java code"
>
<mkdir dir="${javadoc.dir}" />
<javadoc sourcepath="${src.dir}"
destdir="${javadoc.dir}"
protected="true"
windowtitle="plovr"
classpathref="plovr.classpath"
>
<link href="http://download.oracle.com/javase/6/docs/api/" />
<link href="http://docs.guava-libraries.googlecode.com/git/javadoc/" />
<link href="http://google-gson.googlecode.com/svn/tags/gson-1.7.1/docs/javadocs/" />
<link href="http://closure-compiler.googlecode.com/svn/trunk/javadoc/" />
<link href="http://closure-templates.googlecode.com/svn/trunk/javadoc-complete/" />
</javadoc>
</target>
<!--
This runs plovr such that classfiles from build/classes are loaded before
those in plovr.jar. This way, when developing the documentation generation
logic, there is no need to rebuild plovr.jar as part of the build step.
plovr.jar is included in the classpath only to include resources and
classfiles from jars in the lib directory.
-->
<target name="generate-closure-library-jsdoc"
description="Generates HTML documentation for Closure Library">
<exec executable="bash" failonerror="true">
<arg value="${scripts.dir}/generate-closure-library-jsdoc.sh" />
</exec>
</target>
<target name="serve-prod-documentation"
description="run the soyweb server on plovr.com to serve the docs"
depends="generate-options-documentation, javadoc">
<fail unless="jar.present">
The plovr jar has not been built. Run "ant jar" to build it.
</fail>
<mkdir dir="${build.dir.www}" />
<copy todir="${build.dir.www}">
<fileset dir="${www.dir}" includes="**/*" />
</copy>
<java jar="${build.dir}/plovr.jar"
fork="true"
maxmemory="128m">
<arg value="soyweb" />
<arg line="--template base" />
<arg line="--dir ${build.dir.www}" />
<arg line="--static" />
<arg line="--globals ${basedir}/prod-globals.js" />
</java>
</target>
<target name="run-demo" description="run the demo">
<fail unless="jar.present">
The plovr jar has not been built. Run "ant jar" to build it.
</fail>
<java jar="${build.dir}/plovr.jar"
dir="${demo.dir}"
fork="true"
maxmemory="128m">
<arg value="serve" />
<arg value="${demo.dir}/demo-config.js" />
<arg value="${testdata.dir}/modules/plovr-config.js" />
</java>
</target>
<target name="build" depends="jar" />
<target name="all"
description="build all deliverables for the plovr project"
depends="clean,
jar,
test,
generate-options-documentation,
generate-closure-library-jsdoc,
javadoc"
/>
</project>